BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Doug_in_STL
Fluorite | Level 6

My task is to compare the create dates between two SAS datasets and abort processing if one is older than the other. To accomplish this, I'm using PROC DATASETS and outputting to two new datasets, keeping only the "crdate" (creation date) field. Then I want to put the crdate value from each of those two datasets into macro variables so I can query them in a subsequent DATA step.

 

Code:

/*sort one dataset to force a new create date*/

proc sort data=reclassfinal; 
by EntityID;
run;

 

proc datasets library=work nolist nodetails noprint;
  contents data=componentfinal out=work.ComponentDate(keep=crdate);run; /*1st dataset, keeping only crdate*/
  contents data=reclassfinal out=work.ReclassDate(keep=crdate);run; /*2nd dataset (just sorted above), keeping only crdate*/
quit;
 
proc datasets library=work nolist nodetails noprint; /*strip out the default datetime formatting of crdate, just in case*/
  modify ComponentDate;
    attrib _all_ format=;
attrib _all_ informat=;
run;
  modify ReclassDate;
    attrib _all_ format=;
attrib _all_ informat=;
run;
quit;
********** everything above this line works just fine *********************;
data _null_;
  set ReclassDate(in=a) ComponentDate(in=b);
  if a then call symputn('ReclDate',crDate); /*create numeric macro variable because crdate is a number*/
  if b then call symputn('CompDate',crDate);  /*create numeric macro variable because crdate is a number*/
run;
********* this is where things fail *********************;
LOG:
11131 data _null_;
11132 set ReclassDate(in=a) ComponentDate(in=b);
11133 if a then call symputn('RDate',crDate);
                                   -------
                                   251
11134 if b then call symputn('CDate',crDate);
                                     -------
                                      251
ERROR 251-185: The subroutine SYMPUTN is unknown, or cannot be accessed. Check your spelling.
Either it was not found in the path(s) of executable images, or there was incorrect or
missing subroutine descriptor information.
******************** remaining code below ********************;
 
data _null_;
  if &ReclDate > &CompDate then do;
    file print;
put 'Component mapping not completed. OH Alloc process halted.';
abort cancel;
end;
run;
*************************************************** end of code *****************************;
If I replace symputn with just symput, it all works perfectly, with the exception of this note:
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
because crdate is numeric and "symput" is meant for character macro variables.
 
So yes, I can roll along with "symput", but I'd like to know why "symputn" is not working. 
 
Follow-up question:
Is there a more straightforward method to compare create dates among >1 dataset? 
 
Win11Pro X64 environment, v9.4 TS 1M8
Thanks, as always. 
1 ACCEPTED SOLUTION
2 REPLIES 2

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 327 views
  • 1 like
  • 2 in conversation