- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content