The following code runs by itself correctly but when put at end of an autoexec gives no errors and no output. What is wrong with it?
Does an autoexec need special code at end?
data timetrak; time1=time(); date=date(); run;
data timetrak; set timetrak; file print;
put "STAT 755 Clinical Trials" //
"Today's date is " date mmddyy8. " and the time is" time1 hhmm6. //
"Author: Mary A. Marion" /;
run; quit;
Thank you. MM
Does the data set Timetrak exist in the Work library when this code "doesn't run"? If the set is there likely you have something very interesting going on and a Log entry from when it does not run will be needed.
Hint: you can simplify that to
data timetrak; time1=time(); date=date(); file print; put "STAT 755 Clinical Trials" // "Today's date is " date mmddyy8. " and the time is" time1 hhmm6. // "Author: Mary A. Marion" /; run;
and if you don't actually need to use the data set Timetrak for anything else you can use Data _null_;
FWIW, I have had a somewhat similar data step in my Autoexec for more than 8 years and several versions of SAS that displays a countdown to a given date. I have never had it not run or fail to display the result.
Do you get a warning that no ODS destination is active?
Where do you expect the text to appear?
Do you see that the code has been run?
Note that your code can be written as:
data _null_;
TIME=time();
DATE=date();
file print;
put "STAT 755 Clinical Trials" //
"Today's date is " DATE mmddyy8. " and the time is" TIME hhmm6. //
"Author: Mary A. Marion" /;
run;
No warnings about the ODS destination.
I do have the following lines of code in the AUTOEXEC. I wasn't sure how to refer to the SAS work library. The following is not giving an error however.
106 *ODS GRAPHICS;
107 %let
107 ! sasworklocation="/saswork/SAS_workB81000013419_odaws01-usw2.oda.sas.
107 ! com/SAS_workDB5300013419_odaws01-usw2.oda.sas.com";
108 ods listing gpath=&sasworklocation;
SYMBOLGEN: Macro variable SASWORKLOCATION resolves to
"/saswork/SAS_workB81000013419_odaws01-usw2.oda.sas.com/SAS_workDB5
300013419_odaws01-usw2.oda.sas.com"
109
110 *EMF FILE CREATION IN SAS 9.4;
111 %let workdir=%trim(%sysfunc(pathname(work)));
MLOGIC(TRIM): Beginning execution.
MLOGIC(TRIM): This macro was compiled from the autocall file
/pbr/sfw/sas/940/SASFoundation/9.4/sasautos/trim.sas
MLOGIC(TRIM): Parameter VALUE has value
/saswork/SAS_work0B880000230E_odaws03-usw2.oda.sas.com/SAS_work2C9D000023
0E_odaws03-usw2.oda.sas.com
MLOGIC(TRIM): %LOCAL I
SYMBOLGEN: Macro variable VALUE resolves to
/saswork/SAS_work0B880000230E_odaws03-usw2.oda.sas.com/SAS_work2C9D
0000230E_odaws03-usw2.oda.sas.com
MLOGIC(TRIM): %DO loop beginning; index variable I; start value is 100; stop
value is 1; by value is -1.
SYMBOLGEN: Macro variable VALUE resolves to
/saswork/SAS_work0B880000230E_odaws03-usw2.oda.sas.com/SAS_work2C9D
0000230E_odaws03-usw2.oda.sas.com
SYMBOLGEN: Macro variable I resolves to 100
MLOGIC(TRIM): %IF condition %qsubstr(&value,&i,1) ne is TRUE
MLOGIC(TRIM): %GOTO TRIMMED (label resolves to TRIMMED).
SYMBOLGEN: Macro variable I resolves to 100
MLOGIC(TRIM): %IF condition &i>0 is TRUE
SYMBOLGEN: Macro variable VALUE resolves to
/saswork/SAS_work0B880000230E_odaws03-usw2.oda.sas.com/SAS_work2C9D
0000230E_odaws03-usw2.oda.sas.com
SYMBOLGEN: Macro variable I resolves to 100
MLOGIC(TRIM): Ending execution.
112 data _null_;
SYMBOLGEN: Macro variable WORKDIR resolves to
/saswork/SAS_work0B880000230E_odaws03-usw2.oda.sas.com/SAS_work2C9D
0000230E_odaws03-usw2.oda.sas.com
113 file "&workdir./emf94.sasxreg";
114 put '[CORE\PRINTING\PRINTERS\EMF\ADVANCED]';
115 put '"Description"="Enhanced Metafile Format"';
116 put '"Metafile Type"="EMF"';
117 put '"Vector Alpha"=int:0';
118 put '"Image 32"=int:1';
119 run;
NOTE: The file
"/saswork/SAS_ ...
This may be the problem. How to refer to SAS work location?
A young colleague of mine had a problem where the AUTOEXEC would sometimes not execute.
After watching her open SAS and do some work, it was obvious what the problem was.
When she double-clicked on the SAS icon on her desktop (which was customized to use a specific autoexec), everything was fine, the autoexec ran. But sometimes she opened SAS by (in Windows) double-clicking on a program file (a *.sas file), and this used the default AUTOEXEC and the custom autoexec did not execute.
Thank you for the reply. I finally figured out the problem. I had included a reset of ODS options in my code that included an ods _ALL_ close command. I needed to add an ODS listing command at the end and voilà everything runs just fine. Now I'm beginning to wonder what causes the listing command to change? It appears to happen when I simply run a new program outside of the autoexec. Interesting.
*ODS STATEMENTS RESET; options mrecall; %macro odsReset; ods path reset; ods _ALL_ close; ods trace on; ods noptitle; ods graphics on; ods listing; %mend odsReset; %odsReset;
Does the data set Timetrak exist in the Work library when this code "doesn't run"? If the set is there likely you have something very interesting going on and a Log entry from when it does not run will be needed.
Hint: you can simplify that to
data timetrak; time1=time(); date=date(); file print; put "STAT 755 Clinical Trials" // "Today's date is " date mmddyy8. " and the time is" time1 hhmm6. // "Author: Mary A. Marion" /; run;
and if you don't actually need to use the data set Timetrak for anything else you can use Data _null_;
FWIW, I have had a somewhat similar data step in my Autoexec for more than 8 years and several versions of SAS that displays a countdown to a given date. I have never had it not run or fail to display the result.
I am not sure about the work directory. I will watch for that. I just tried an old version that ran and TimeTrak was in the work library so right now I think it best I just stay with what I have.
I have been wanting to save my graphs and am including the following code in my AUTOEXEC. It appears before the TimeTrak code when TimeTrak is at the end of the AUTOEXEC. That is a little suspicious. It may be affecting the work library? Can you give me a better way to refer to the SAS work location?
106 *ODS GRAPHICS;
107 %let
107 ! sasworklocation="/saswork/SAS_workB81000013419_odaws01-usw2.oda.sas.
107 ! com/SAS_workDB5300013419_odaws01-usw2.oda.sas.com";
108 ods listing gpath=&sasworklocation;
SYMBOLGEN: Macro variable SASWORKLOCATION resolves to
"/saswork/SAS_workB81000013419_odaws01-usw2.oda.sas.com/SAS_workDB5
300013419_odaws01-usw2.oda.sas.com"
109
Could that be causing some of the difficulty here? I had SAS studio give me the location which is how I got this long set of instructions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.