%let DorsHHFPath =/dorsshare/HHFit;
%put &DorsHHFPath;
%Let StateList=ga il in ky md mi;
%macro fetchstate(Statelist= ,
Currdate= );
%Let cnt=1;
%Let Thisstate=%scan(&StateList, &cnt, %Str( ) );
%Do %While (&Thisstate NE );
proc import out= &Thisstate
datafile="&DorsHHFPath/&Thisstate./&Thisstate._HHF_STM_ToState_&CURRDATE_KEY._01.csv"
dbms=CSV replace ;
getnames=no;
datarow=3;
run;
/*** Advance counter and select next state ***/
%Let cnt=%eval(&cnt + 1);
%Let Thisstate=%scan(&StateList, &cnt, %Str( ) );
%End;
%Mend;
%fetchstate(StateList=&StateList,
Currdate=&Currdate);
&CURRDATE_KEY represents todays date. This macro script creates a work file if the date extention is todays date. If not the script generates an error. Is there a way to avoid the error with some type of else statement that says 'no file' ??
Check SAS 9.4 macro appendix for a macro that shows how this can be executed, where empty data set gets an empty record. There example is for export but I think you’ll get the idea.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.