Hi, I'm trying to create a date macro variable and then insert it into an infile statement where I'm reading in a text file. However, I'm getting the following error. I've read through some of the posts and see similar posts but can't find one that specifically addresses my example here. Could you please help?
Andy
DATA _NULL_ ;
FORMAT CURR_YR LST_YR YEAR4.;
CURR_YR = INTNX('YEAR',TODAY(),0);
LST_YR = INTNX('YEAR',TODAY(),-1);
CALL SYMPUT('CURR_YR','"'||PUT(CURR_YR,YEAR4.)||'"');
CALL SYMPUT('LST_YR','"'||PUT(LST_YR,YEAR4.)||'"');
RUN;
%PUT
CURRENT YEAR: &CURR_YR
LAST YEAR: &LST_YR
;
INFILE '/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_'&LST_YR'.txt' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2;
LOG:
Here's how to include a macro variable within a text string. Notice the extra dot, as well as double quotes instead of single quotes:
INFILE "/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_&LST_YR..txt" delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2;
try this
INFILE '/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_'&LST_YR'.txt' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2;INFILE '/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_"&LST_YR.".txt' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2;
Here's how to include a macro variable within a text string. Notice the extra dot, as well as double quotes instead of single quotes:
INFILE "/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_&LST_YR..txt" delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.