BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

%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' ??

2 REPLIES 2
Reeza
Super User

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. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 596 views
  • 0 likes
  • 3 in conversation