What is my issue with variable in SAS code? - variables

Can somebody help me please?
I am running small program in SAS. .
Data import works fine, but I am getting error with variable pocet_bodu.
Do you have any idea why is it happening please?
ERROR:
85
86 %web_open_table(WORK.IMPORT);
87
88 proc univariate data=work.import normal plot;
89 var pocet_bodu;
ERROR: Variable POCET_BODU not found.
90 histogram pocet_bodu/normal;
ERROR: Variable POCET_BODU not found.
91 qqplot pocet_bodu/normal (mu=est sigma=est);
ERROR: Variable POCET_BODU not found.
92
93 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
94
95 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
107
CODE:
%web_drop_table(WORK.IMPORT);
FILENAME REFFILE '/folders/myfolders/data-mining/data/du1_1.xlsx';
PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;
PROC CONTENTS DATA=WORK.IMPORT;
RUN;
%web_open_table(WORK.IMPORT);
proc univariate data=work.import normal plot;
var pocet_bodu;
histogram pocet_bodu/normal;
qqplot pocet_bodu/normal (mu=est sigma=est);
run;

Error was in imported excel file... it needed to define var name there as well :)

Related

SAS : Data does not exist even tough they do

I am new in SAS environment. Maybe this is a stupid question but I cannot figure it out.
LIBNAME CODY '/folders/myfolders/Cody';
data In_Both
Missing_Name(drop = Name);
merge purchase(in=In_Purch)
inventory(in=In_Invent);
by Model;
if In_Purch and In_Invent then output In_Both;
else if In_Invent and not In_Purch then output Missing_Name;
run;
This is the error I receive
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 LIBNAME CODY '/folders/myfolders/Cody';
NOTE: Libref CODY was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Cody
74
75 data In_Both
76 Missing_Name(drop = Name);
77 merge purchase(in=In_Purch)
78 inventory(in=In_Invent);
ERROR: File WORK.PURCHASE.DATA does not exist.
ERROR: File WORK.INVENTORY.DATA does not exist.
79 by Model;
80 if In_Purch and In_Invent then output In_Both;
81 else if In_Invent and not In_Purch then output Missing_Name;
82 run;
It seems that SAS cannot find the files even though they exists.
I'm using SAS university Edition.
The code should give me 2 datasets, one with the merged observation and another one with the unmerged observations.
Is there a specific way to load the datasets I need?
The two datasets are in format sas7bdat
Thanks everyone for the help!
Change the merge statement in your code to
merge
CODY.purchase(in=In_Purch)
CODY.inventory(in=In_Invent)
;
The log is telling you the step is looking for tables in the WORK library, not CODY
Let's look at the original code.
data In_Both Missing_Name(drop = Name);
merge
purchase(in=In_Purch)
inventory(in=In_Invent)
;
by Model;
if In_Purch and In_Invent then output In_Both;
else
if In_Invent and not In_Purch then output Missing_Name;
run;
The data set names purchase and inventory in the merge do not include a <libref>.. When a libref is not present, SAS will default to the WORK folder.
The error messages in the log clearly tells you the problem
ERROR: File WORK.PURCHASE.DATA does not exist.
ERROR: File WORK.INVENTORY.DATA does not exist.
You can see the step was looking for WORK.PURCHASE and WORK.INVENTORY and did not find them (because they are in the CODY library)
Change the data sets being merged to include the appropriate library, thus you want CODY.purchase and CODY.inventory

STM32 Atollic TrueSTUDIO - Graphical view of the Memory

I'm using Atollic TrueSTUDIO for STM32 as an Eclipse Based IDE to perform Digital Signal Processing on audio signal. I'm looking for a way to plot an array (16 bits audio samples) from RAM memory. For the moment I'm using :
The memory View
The SWV real time data time line
None of this tools are powerful to analyse signal on an array, and it doesn't have to be on real time : Just ploting an array after reaching a breakpoint.
Is there an Eclipse Plugin or some other ways to do this ?
I'm considering to export the RAM memory and in a file and plot it in Matlab, but it seems really inapropriate for such a simple thing.
Thanks for any advices
In Atollic, you can easily attach gdb commands to breakpoints. Doing this, allows you to automaticly dump any variables. Additionally, you can execute an external programm once afterwards, to plot the content of the dumped variable.
To do so, goto breakpoint properties and create a new action. Select "Debugger Command Action" and use dump binary value x.bin x to dump variable x to file x.bin
You can also start a python script from the breakpoint to plot the data.
Use an additonal "External Tool Action" and select your python location. Make sure to select your current Working Dictonary. Use the arguments to pass the full path of the python file. The following file will import a float array and plot it.
import struct
import numpy as np
import matplotlib.pyplot as plt
import os
def readBinaryDump(filename):
result = []
N=8
with open(filename,'rb') as f:
while(True):
b = f.read(4*N);
if len(b) ==0:
break
fn = "f"*N
result.append(struct.unpack(fn,b))
result = np.array(result)
return result.ravel()
plt.plot(readBinaryDump("x.bin"))
Don't forget to add the actions to the current breakpoint. Now once the breakpoint is reached, the variable should be dumped and plotted automaticly.
While it's surprising nothing could be embeded in Atollic/Eclipse, I followed the idea of writing an specific application. Here are the steps I used :
Dump Memory :
Debug your software
Stop on a BreakPoint
View > Memory > Export Button > Format : "Plain Text"
The file representing a sine wawe looks like this :
00 00 3E 00 7D 00 BC 00 FB 00 39 01 78 01
B7 01 F6 01 34 02 73 02 B2 02 F0 02 2F 03
You should read these int16 samples like this :
1. 0x0000
2. 0x003E
3. 0x007D
4. etc...
Write this Matlab script :
fileID = fopen('your_file','r');
samples = textscan(fileID,'%s')
fclose(fileID);
samples = samples{1};
words = strcat(samples(2:2:end,1), samples(1:2:end,1));
values = typecast(uint16(hex2dec(words)),'int16');
plot(values) ;
The sinus wave plotted in Matlab
While there aren't any Eclipse plugins that would do what you're asking for that I'm personally aware of, there's STM Studio whose main purpose is displaying variables in real-time. It parses your ELF file to get the available variables, so the effort to at least give it a try should be minimal.
It's available here: https://www.st.com/en/development-tools/stm-studio-stm32.html
ST-Link is required to run it.
Write the simple app in C#. Use semi hosting to dump the memory to the text file. Open it and display.
Recently I had problem with MEMS-es and this was written in less than one hour. IMO (In My Opinion) it is easier to write program which will visualize the data instead of wasting hours or days searching for the ready made one:

Octave - Fetch function

I would like to use the Fecth function to get some data, looking at the example in the .m file I can't seem to run the function with the following command;
fetch(yahoo(), "yhoo", "01-Jul-2015", "10-Jul-2015", "w")
This gives me the following error;
error: dates(_,4): but dates has size 0x0
error: called from
fetch_yahoo at line 69 column 12
fetch at line 124 column 18
Does anyone have any idea what's going wrong here? I've tried changing the 'w' to 'd' but have no idea what's going wrong?

using macro variable to read folder content in SAS 9.4 [duplicate]

This question already has answers here:
Why won't my macro variable resolve?
(2 answers)
Closed 5 years ago.
I'm trying to get the list of files in a directory with a SAS macro that uses a macro variable to specify dynamically the folder name. The code I run is the following:
%macro veicolo(codice_veicolo);
filename pipedir pipe ' dir "some_path\&codice_veicolo" /S' lrecl=5000;
data &codice_veicolo;
infile pipedir truncover;
input line $char1000.;
length directory $1000;
retain directory;
if line =' ' or
index(upcase(line),'<DIR>') or
left(upcase(line))=:'VOLUME' then
delete;
if left(upcase(line))=:'DIRECTORY OF' then
directory=left(substr(line,index(upcase(line),'DIRECTORY OF')+12));
if left(upcase(line))=:'DIRECTORY OF' then
delete;
if input(substr(line,1,10),?? mmddyy10.) = . then
substr(line,1,10)='12/31/2999';
date=input(substr(line,1,10),?? mmddyy10.);
format date mmddyy10.;
run;
proc sort data=&codice_veicolo;
by directory descending date;
run;
data folder_&codice_veicolo(drop=i line);
set &codice_veicolo;
by directory;
length filename $75;
retain number_of_files_in_directory directory_size;
if first.directory then
do;
number_of_files_in_directory=input(scan(line,2,' '),32.);
call symput(nfiles,number_of_files_in_directory);
directory_size=input(scan(line,4,' '),comma32.);
end;
file_size=input(scan(line,3,' '),comma32.);
filename=' ';
do i=4 to 100;
filename=trim(left(filename))||' '||scan(line,i,' ');
if scan(line,i,' ')=' ' then
leave;
end;
if index(upcase(line),'FILE(S)') then
delete;
if date ge '30DEC2999'd then
delete;
run;
%mend;
When I then execute the macro with the argument codice_veicolo being the name of the folder I want to search in, I get the following error:
Output Err std:
The system cannot find the path specified.
NOTE: 20 records were read from the infile PIPEDIR.
The minimum record length was 0.
The maximum record length was 90.
NOTE: The data set WORK.JL6AME1A6FK000442 has 2 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.01 seconds
I supposed that for some reason it could not resolve the macro variable, but if I run:
%let pgmpath = %sysfunc(pathname(pipedir));
%put &pgmpath;
I get the proper path and the proper directory, therefore I assume the problem is in the infile statement. The code runs fine without using macro variables.
I am using SAS 9.4 on Windows 8. Any ideas??
Thank you in advance :)
Luca
Macro variable references are not expanded inside of single quotes.
Try this instead.
filename pipedir pipe %sysfunc(quote(dir /s "some_path\&codice_veicolo")) lrecl=5000;

View executed sql statements from a crash dump

How can I view executed SQL stored procedures from a memory crash dump of a C# .net application?
The information you want might not be available any more. The objects representing connections, queries and results may already have been garbage collected.
If you know the name of the class that is used for a query, you can use windbg, load the sos extension and use the !dumpheap -type <classname> command to find those objects. Then use !do <address> to display the details of such an object. This might reveal the statement behind it.
If you're looking for a specific query, download the netext extension. It comes with the !wfrom command which allows you to select objects from the .NET heap based on criteria that you define.
This question has no trivial answer and many experienced debuggers had to face this issue one way of another. Getting the information for a single SQL command is tedious, but straightforward. For many it is difficult. I was helping a colleague on a situation like this and put together this solution. It requires NetExt (download the zip file): https://github.com/rodneyviana/netext/tree/master/Binaries
0:067> !windex
Starting indexing at 14:18:54 PM
1000000 objects...
2000000 objects...
3000000 objects...
4000000 objects...
Indexing finished at 14:19:04 PM
399,314,598 Bytes in 4,049,972 Objects
Index took 00:00:10
0:067> .foreach ({$addr} {!wfrom -type *.sqlcommand -nospace -nofield where (_commandType == 4) select _parameters._items._items}) { r #$t1= {$addr} ;!wfrom -type *.sqlcommand -nofield -nospace where (_parameters._items._items==$dbgeval("#$t1")) "\n", _commandText," [",$addr(),"]\n========================"; !wfrom -nospace -nofield -array {$addr} _parameterName,"=",$pp(_value) }
dbo.proc_getSiteIdOfHostHeaderSite [00000001011FCD90]
========================
#RETURN_VALUE=0n0
#HostHeader=sp.contoso.com
#RequestGuid={00000000-0000-0000-0000-000000000000}
proc_GetTpWebMetaDataAndListMetaData [0000000101D98DA0]
========================
#RETURN_VALUE=0n0
#WebSiteId={2815591d-55c8-4caf-842c-101d8807cb2a}
#WebId=NULL
#Url=
#ListId=NULL
#ViewId=NULL
#RunUrlToWebUrl=1
#DGCacheVersion=0n2
#SystemId=69 3a 30 29 2e 77 7c 73 2d 31 2d 35 2d 32 31 2d 31 33 38 35 31 37 34 39 39 32 2d 39 37 39 39 35 i:0).w|s-1-5-21-1385174992-97995 (...more...)
#MetadataFlags=0n18
#ThresholdScopeCount=0n5000
#CurrentFolderUrl=NULL
#RequestGuid={a00a0b30-1fcc-44d6-8346-ec20f8c49304}
proc_EnumLists [000000010236EDF0]
========================
#RETURN_VALUE=0n0
#WebId={a0a099b2-6023-4877-a7c1-378ec68df759}
#Collation=Latin1_General_CI_AS
#BaseType=NULL
#BaseType2=NULL
#BaseType3=NULL
#BaseType4=NULL
#ServerTemplate=NULL
#FMobileDefaultViewUrl=NULL
#FRootFolder=NULL
#ListFlags=0n-1
#FAclInfo=0n1
#Scopes=NULL
#FRecycleBinInfo=NULL
#UserId=NULL
#FGP=NULL
#RequestGuid={a00a0b30-1fcc-44d6-8346-ec20f8c49304}
(...)