The EG log is quite messy for even the simplest piece of SAS code. For example submitting the following code:
data _null_;
run;
Will produce the following log:
1 The SAS System 11:12 Wednesday, May 13, 2015
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROJECTPATH='';
5 %LET _CLIENTPROJECTNAME='';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR STYLE=HtmlBlue
12 ! STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/5.1/Styles/HtmlBlue.css") NOGTITLE NOGFOOTNOTE
12 ! GPATH=&sasworklocation ENCODING=UTF8 options(rolap="on");
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
13
14 GOPTIONS ACCESSIBLE;
15 data _null_;
16 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
17
18 GOPTIONS NOACCESSIBLE;
19 %LET _CLIENTTASKLABEL=;
20 %LET _CLIENTPROJECTPATH=;
21 %LET _CLIENTPROJECTNAME=;
22 %LET _SASPROGRAMFILE=;
23
24 ;*';*";*/;quit;run;
25 ODS _ALL_ CLOSE;
26
27
28 QUIT; RUN;
29
That's quite a lot of completely useless info being returned, that obscures the only part of the log I want to see (lines 15:16):
15 data _null_;
16 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Is there any way to change this default behaviour? I've poked through the options and nothing jumped out at me.
Tools > Options... > Results General > Uncheck "Show Generated Wrapper Code in SAS Log"
Related
I am pretty new to SAS, I am trying to see which songs/artists/albums have appeared most on my spotify most played csv's (2017-2020). I am getting stuck very early on trying to just set the 2017 csv as a data set. Is there anything anyone can see that I am doing wrong? Seems like this step should be pretty straight forward.
data Spotify_2017;
infile='C:\Users\your_top_songs_2017.csv' dlm=’09’x dsd firstobs=2;
input Track URI Track Name Artist URI Artist Name Album URI Album Name Album Release Date Disc Number Track Number Track Duration Explicit Popularity Added By Added At;
run;
and here is the log:
1 The SAS System 10:18 Friday, January 15, 2021
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Spotify.sas';
4 %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='C:\Users\xxx\Desktop\Spotify\Spotify.sas';
9 %LET _SASPROGRAMFILEHOST='USRDUL-PC0NNXU1';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=SVG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17 FILENAME EGHTML TEMP;
18 ODS HTML5(ID=EGHTML) FILE=EGHTML
19 OPTIONS(BITMAP_MODE='INLINE')
20 %HTML5AccessibleGraphSupported
21 ENCODING='utf-8'
22 STYLE=HtmlBlue
23 NOGTITLE
24 NOGFOOTNOTE
25 GPATH=&sasworklocation
26 ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27
28 data Spotify_2017;
29 infile='C:\Users\pcardella\Desktop\Spotify\C:\Users\xxx\Desktop\Spotify\your_top_songs_2017.csv' dlm=’09’x dsd
___
388
76
29 ! firstobs=2;
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
30 input Track URI Track Name Artist URI Artist Name Album URI Album Name Album Release Date Disc Number Track Number Track
30 ! Duration Explicit Popularity Added By Added At;
31 run;
ERROR: No DATALINES or INFILE statement.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SPOTIFY_2017 may be incomplete. When this step was stopped there were 0 observations and 16 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
32
33 %LET _CLIENTTASKLABEL=;
34 %LET _CLIENTPROCESSFLOWNAME=;
35 %LET _CLIENTPROJECTPATH=;
36 %LET _CLIENTPROJECTPATHHOST=;
37 %LET _CLIENTPROJECTNAME=;
38 %LET _SASPROGRAMFILE=;
39 %LET _SASPROGRAMFILEHOST=;
2 The SAS System 10:18 Friday, January 15, 2021
40
41 ;*';*";*/;quit;run;
42 ODS _ALL_ CLOSE;
43
44
45 QUIT; RUN;
46
infile is a statement and does not need an equals sign. The syntax is:
infile 'file location here' <options>;
data Spotify_2017;
infile 'C:\Users\your_top_songs_2017.csv' dlm=’09’x dsd firstobs=2;
input Track URI Track Name Artist URI Artist Name Album URI Album Name Album Release Date Disc Number Track Number Track Duration Explicit Popularity Added By Added At;
run;
One way to help learn importing raw files using the data step is to use proc import. proc import will import the data and generate data step code for you in the log when importing csv files. You can study it to see how it works and try to replicate it.
proc import
file = 'C:\Users\your_top_songs_2017.csv'
out = spotify_2017
dbms = csv
replace;
run;
Also, a great option to help make logs more readable in Enterprise Guide is to disable autogenerated code. Go to Tools -> Options -> Results -> General -> uncheck "Show generated wrapper code in SAS log"
As the title suggests, I experience some unexpected performance behaviour while working with a datastep.
A. The following code executes in 0.01 sec. So far so good.
data policen_roh;
set dwhprod.tbwh_kdu_detail_hi(
keep=
kdu_dt_id police_nr record_typ kdnr bag betrag_akt ursp_beginn_dt beginn_dt ablauf_dt storno_dt
where=(
police_nr=406045267
and record_typ='P'
)
)
;
run;
B. Additionally I have to filter a date, which is stored in a date-id, starting at 1 for 01/01/1850. Since I created formats to convert the date-id to a year (integer), I added the line input(put(kdu_dt_id, tag_id2jahr.),best.) ge 2017.
Works as expected. No problem here. I get my 15 expected records, and execution time increases marginally to 0.02 sec:
data policen_roh;
set dwhprod.tbwh_kdu_detail_hi(
keep=
kdu_dt_id police_nr record_typ kdnr bag betrag_akt ursp_beginn_dt beginn_dt ablauf_dt storno_dt
where=(
police_nr=406045267
and input(put(kdu_dt_id, tag_id2jahr.),best.) ge 2017
and record_typ='P'
)
)
;
run;
C. Now here is the problem: In an effort to speed up my code for larger datasets, I replaced
input(put(kdu_dt_id, tag_id2jahr.),best.) ge 2017
with
kdu_dt_id gt 60997 - the equivalent of 01/01/2017.
To my understanding, this should be way faster, since there is no put/input calculation required. However, while this returns the same result as B., execution time increases to roughly 30.00 seconds.
What is did I miss?
Appendix: Log for further reference
1 The SAS System 13:56 Wednesday, February 7, 2018
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Programm';
4 %LET _CLIENTPROJECTPATH='R:\Projekte\20180125 Erneuerungsprovisionen\Erneuerungsprovisionen.egp';
5 %LET _CLIENTPROJECTNAME='Erneuerungsprovisionen.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGHTML TEMP;
12 ODS HTML(ID=EGHTML) FILE=EGHTML
13 ENCODING='utf-8'
14 STYLE=HtmlBlue
15 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHOME/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
16 ATTRIBUTES=("CODEBASE"="http://www2.sas.com/codebase/graph/v94/sasgraph.exe#version=9,4")
17 NOGTITLE
18 NOGFOOTNOTE
19 GPATH=&sasworklocation
20 ;
NOTE: Writing HTML(EGHTML) Body file: EGHTML
21
22 GOPTIONS ACCESSIBLE;
23 data policen_roh;
24 set dwhprod.tbwh_kdu_detail_hi(
25 keep=
26 kdu_dt_id police_nr record_typ kdnr bag betrag_akt ursp_beginn_dt beginn_dt ablauf_dt storno_dt
27 where=(
28 police_nr=406045267
29 and kdu_dt_id gt 60997
30 and record_typ='P'
31 )
32 )
33 ;
34 run;
NOTE: There were 14 observations read from the data set DWHPROD.TBWH_KDU_DETAIL_HI.
WHERE (police_nr=406045267) and (kdu_dt_id>60997) and (record_typ='P');
NOTE: The data set WORK.POLICEN_ROH has 14 observations and 10 variables.
NOTE: Compressing data set WORK.POLICEN_ROH increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
real time 1:10.44
cpu time 0.03 seconds
35
36 GOPTIONS NOACCESSIBLE;
37 %LET _CLIENTTASKLABEL=;
38 %LET _CLIENTPROJECTPATH=;
39 %LET _CLIENTPROJECTNAME=;
40 %LET _SASPROGRAMFILE=;
41
42 ;*';*";*/;quit;run;
43 ODS _ALL_ CLOSE;
44
45
46 QUIT; RUN;
2 The SAS System 13:56 Wednesday, February 7, 2018
47
My guess is that your underlying table is on a database, and the removal of the input / put functions changed the query execution such that it is no longer making use of available indexes.
A bit counterintuitive, but try removing kdu_dt_id gt 60997 from your where clause and put it in a gating if statement instead.
data policen_roh;
set dwhprod.tbwh_kdu_detail_hi(
keep=
kdu_dt_id police_nr record_typ kdnr bag betrag_akt ursp_beginn_dt beginn_dt ablauf_dt storno_dt
where=(
police_nr=406045267
and record_typ='P'
)
)
;
if kdu_dt_id gt 60997;
run;
Alternatively speak to your dba about tuning your database if this is a query you will run often.
For more information, you could re-write your query using proc sql, with the _tree option (to view the execution plan). You could then use the _method option to play around / tune that plan.
Also, check out options sastrace=',,,d' sastraceloc=saslog; to show your dba more info on what is being sent to the database in terms of the underlying SQL query.
I'm writing SAS code and experiencing an error that seems to be caused by SAS generated language in code. I've been using SAS awhile and never experienced this. Any help/advice would be appreciated. I've cut out some of the middle code so this is not so long.
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROJECTPATH='Z:\ACS\Decision Sciences\Analysis\Code\AAU_Analysis.egp';
5 %LET _CLIENTPROJECTNAME='AAU_Analysis.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 FILENAME EGSR TEMP;
11 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
12 STYLE=HtmlBlue
13 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/6.1/Styles/HtmlBlue.css")
14 NOGTITLE
15 NOGFOOTNOTE
16 GPATH=&sasworklocation
17 ENCODING=UTF8
18 options(rolap="on")
19 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
20
21 options nomprint nomlogic;
22
23 libname acs 'F:\SAS_data\ACS';
NOTE: Libref ACS was successfully assigned as follows:
Engine: V9
Physical Name: F:\SAS_data\ACS
24 %include 'F:\SAS_data\Lysbet\sas_macro_library.sas';
171
173 %macro transform_survey;
174
175 data acs.aau_data_transformed;
176 set acs.aau_data;
177 length brand $3.;
189 %do i=1 %to 10;
190 antonym_pair=&i;
191 %do j = 1 %to &n;
192 %let val = %scan(&lst, &j);
193 brand=&val;
194 suppress_flag1=Q12&val.Flag1;
195 suppress_flag2=Q12&val.Flag2;
196 score=Q_12&val._&i;
197 output;
198 %end;
199 brand='ACS';
200 score=Q_9_&i;
201 output;
202 %end;
205 %mend;
206 %transform_survey;
207
208 %LET _CLIENTTASKLABEL=;
209 %LET _CLIENTPROJECTPATH=;
210 %LET _CLIENTPROJECTNAME=;
211 %LET _SASPROGRAMFILE=;
212
213 ;*';*";*/;quit;run;
____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
That means somewhere (probably in the included macro library, or in previously submitted code) you have an unmatched quote (or unmatched %macro/%mend or other similar pair, but it looks like " if you have things lined up correctly).
Thanks for all input but classic case of user error. I forgot the run statement for the data step in my macro. I knew it was going to end up being something seemingly unrelated.
Whenever I submit code in SAS University Edition, statements like this are inserted automatically and show up in the log:
OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
What causes this, and is there a way to disable it? I'm not even sure whether these statements are doing anything, as all the associated content is still displayed in the log.
After following Dwal's suggestion below, here is all of the additional generated code:
1 OPTIONS NOSYNTAXCHECK;
2 TITLE;
3 FOOTNOTE;
4 OPTIONS LOCALE=en_US DFLANG=LOCALE;
5 DATA _NULL_;
6 VALUE=GETOPTION("VALIDVARNAME");
7 CALL SYMPUT("_WEBVVN", VALUE);
8 RUN;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
9 OPTIONS VALIDVARNAME=V7;
10 FILENAME _HTMLOUT TEMP;
11 FILENAME _GSFNAME TEMP;
12 FILENAME _DATAOUT TEMP;
13 %LET SYSCC=0;
14 %LET _CLIENTAPP=SAS Studio;
15 %LET _CLIENTAPPVERSION=3.3;
16 %LET _SASPROGRAMFILE = %BQUOTE();
17 %LET _BASEURL = %BQUOTE(http://localhost:10080/SASStudio/);
18 %LET _EXECENV=SASProgrammer;
19 DATA _NULL_;
20 CALL SYMPUT("GRAPHINIT","");
21 CALL SYMPUT("GRAPHTERM","");
22 RC=TSLVL('GEOCODE');
23 _ERROR_=0;
24 IF (RC^=' ') THEN DO;
25 CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;");
26 CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;");
27 END;
28 RUN;
NOTE: Argument 1 to function TSLVL('GEOCODE') at line 22 column 4 is invalid.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
29 DATA _NULL_;
30 RC=SYSPROD("PRODNUM002");
31 IF (RC^=1) THEN DO;
32 CALL SYMPUT("GRAPHINIT","");
33 CALL SYMPUT("GRAPHTERM","");
34 END;
35 RUN;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
36 %LET _DATAOUT_MIME_TYPE=;
37 %LET _DATAOUT_NAME=;
38 %LET _DATAOUT_TABLE=;
39 %LET _DATAOUT_URL=;
40 %SYMDEL _DATAOUT_MIME_TYPE _DATAOUT_NAME _DATAOUT_URL _DATAOUT_TABLE;
41 %LET _SASWS_ = %BQUOTE(/folders/myfolders);
42 %LET _SASWSTEMP_=%BQUOTE(/folders/myfolders/.images/c1930fcb-2ffb-4ae0-8bfe-624b39b851b9);
43 ODS LISTING CLOSE;
44 OPTIONS PRINTERPATH=PDF;
45 ODS AUTONAVIGATE OFF;
46 ODS GRAPHICS ON;
47 ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8 FILE=_HTMLOUT (TITLE='Results: Program') STYLE=Htmlblue
47 ! OPTIONS(BITMAP_MODE='INLINE' SVG_MODE='INLINE' CSS_PREFIX='.ods_c1930fcb-2ffb-4ae0-8bfe-624b39b851b9'
47 ! BODY_ID='div_c1930fcb-2ffb-4ae0-8bfe-624b39b851b9' );
NOTE: Writing HTML5(WEB) Body file: _HTMLOUT
48 &GRAPHINIT;
49 OPTIONS FIRSTOBS=1;
50 OPTIONS OBS=MAX;
51 OPTIONS DTRESET DATE NUMBER NOTES;
52 OPTIONS NOSYNTAXCHECK;
53
The bit I actually submitted:
54 data _null_;
55 put "Hello";
56 run;
Hello
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
And then some more afterwards:
57
58 OPTIONS NOSYNTAXCHECK;
59 ODS HTML CLOSE;
60 &GRAPHTERM; ;*';*";*/;RUN;QUIT;
61 QUIT;RUN;
62 OPTIONS VALIDVARNAME=&_WEBVVN;
63 %SYMDEL _WEBVVN;
64 ODS HTML5 (ID=WEB) CLOSE;
65
66 FILENAME _GSFNAME;
NOTE: Fileref _GSFNAME has been deassigned.
67 DATA _NULL_;RUN;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
67 ! OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
68
There's several places that options can be set in SAS - the below list are in order of precedence (ie #1 supercedes #2 etc):
Restricted options table, if it exists (if you're on a university sever these may have been set)
OPTIONS statement (or SAS System Options window)
Autoexec file (that contains an OPTIONS statement)
Command-line specification
Configuration file specification
SAS system default settings.
You can check the actual values of these options by sumbitting the following which will output a list of all the system options and their current values:
proc options define ;
run ;
From what you're saying, it sounds like the log is still outputing notes/source lines yes? If your seeing OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; in your log then it's just a guess but it could be that the statement is coming from an autoexec file (#3) which is then being superceded by unitversity restricted options (#1).
You can check this from the output of the proc options statement above by looking for the value of the AUTOEXEC option as this will specify the path to the autoexec file being submitted (if there is one).
I am receiving a very frustrating SAS error when trying to use PROC PANEL.
"Expecting a name"
I have created some sample code that reproduces the error. Any ideas on what I'm missing?
876 PROC SORT DATA=TEMP OUT=TEMPSORTED;
877 BY OBS_DATE;
878 RUN;
NOTE: There were 26 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMPSORTED has 26 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
879
880 PROC PANEL DATA=TEMPSORTED;
881 ID OBS_DATE;
_
22
****ERROR 22-322: Expecting a name.****
882 LAG DEGREES_F(1) / OUT=TEMP_W_LAG;
ERROR: Variable NAME not found.
883 RUN;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PANEL used (Total process time):
real time 0.06 seconds
cpu time 0.00 seconds
Here is an entire section of code which reproduces the error:
DATA TEMP;
INPUT OBS_DATE mmddyy10. DEGREES_F #17;
FORMAT OBS_DATE mmddyy10.;
datalines;
11/01/2014 44
11/02/2014 53
11/03/2014 64
11/04/2014 61
11/05/2014 63
11/06/2014 52
11/07/2014 45
11/08/2014 49
11/09/2014 53
11/10/2014 65
11/11/2014 61
11/12/2014 33
11/13/2014 31
11/14/2014 29
11/15/2014 33
11/16/2014 33
11/17/2014 25
11/18/2014 21
11/19/2014 33
11/20/2014 30
11/21/2014 36
11/22/2014 54
11/23/2014 54
11/24/2014 51
11/25/2014 30
11/26/2014 32
;
PROC SORT DATA=TEMP OUT=TEMPSORTED;
BY OBS_DATE;
RUN;
PROC PANEL DATA=TEMPSORTED;
ID OBS_DATE;
LAG DEGREES_F(1) / OUT=TEMP_W_LAG;
RUN;
Proc Panel is for when data is both time series and cross sectional. Your data doesn't appear to be cross sectional, but time series alone.
Additionally ID requires a Cross Section ID and Time Variable. You could try to simply add a cross section ID and see if that gives you what you want, but you may want to explore other more appropriate procedures.