SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
agbpilot
Obsidian | Level 7

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:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 DATA USER.LST_YR_VALUES (DROP=RP APPRAISAL_YEAR RECORD_TYPE SEQUENCE_NO PIDN TAD_MAP MAPSCO STATE_USE_CODE
73 ! NUM_SPECIAL_DIST DEED_BOOK DEED_PAGE
74 ARB_INDICATOR CENTRAL_HEAT_IND CENTRAL_AIR_IND STRUCTURE_COUNT FROM_ACCTS GIS_LINK INSTRUMENT_NO OVERLAP_FLAG
75 GARAGE_CAPACITY OWNER_ZIP4);
76 INFILE '/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_'&LST_YR'.txt' delimiter = '|' MISSOVER DSD
76 ! lrecl=32767 firstobs=2;
NOTE: Line generated by the macro variable "LST_YR".
76 '/folders/myfolders/tarrant/input_data/prior_yr/PropertyData_R_'"2018"
______
23
ERROR 23-2: Invalid option name "2018".
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

View solution in original post

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

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;

Astounding
PROC Star

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;

agbpilot
Obsidian | Level 7
Thank you, this works!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2120 views
  • 2 likes
  • 3 in conversation