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;
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.