BookmarkSubscribeRSS Feed
AliMN
Calcite | Level 5

Hello,

I'm trying to understand what this code is doing as I'm having the error below when run and if there's away that can be modified would be great. the code was written some one else who is not around any more. Much appreciated your input.

data _null_;

suffix = put(&DT,yymmddn8.);

call symput('DATE', suffix);

run;

24         data _null_;

25        

26         suffix = put(&DT,yymmddn8.);

NOTE: Line generated by the macro variable "DT".

26         16Dec2013

             _______

             22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,

              LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=. 

27        

28         call symput('DATE', suffix);

29     

30         run;

4 REPLIES 4
snoopy369
Barite | Level 11

&DT would need to resolve to "16Dec2013"d, not 16Dec2013 with no quotes or d ("xxx"d is a "date constant").  It's possible in the past the macro variable was defined as the numeric equivalent of the date, but now you're trying to use the text (which is fine).


data _null_;

suffix = put("&DT"d,yymmddn8.);

call symput('DATE', suffix);

run;

Otherwise, you could consider trying something like

%let date=%sysfunc(today(),YYMMDDN8.);

if it's intended to be today, for example; other similar solutions exist for specifying particular dates, depending on how your particular date is arrived at.

Reeza
Super User

I'd go back and check how DT should be inputted/created. My guess is the macro variable isn't being set appropriately or how the original programmer intended.

You're less likely to cause issues further down the line if the variable is used in other places if you change it at the "top" rather than in the middle of the program.

NaveenSrinivasan
Calcite | Level 5

Hi,

I believe you have pasted rather a piece of a script out of a process and trying to understand it. However, my sincere opinion is that it would make more sense for you to review the following preceding and subsequent steps in the same script just to understand how the resolved DT macro variable is being applied.

I'd even suggest you to try running your script with hard coded values  to get a better understanding just to know what this macro variable is doing.

Thanks,

Naveen

Tom
Super User Tom
Super User

For that code to work the macro variable DT would either need to be a date literal such as '16dec2013'd or an actual number of days since 1/1/1960.

You can either fix the code segment posted to add the quotes and the letter d to convert your macro variable value into a date literal.


suffix = put("&DT"d,yymmddn8.);

Or change how the macro variable is set so that it contains a value that is a valid date.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 959 views
  • 0 likes
  • 5 in conversation