BookmarkSubscribeRSS Feed
KannanBaskar
Calcite | Level 5

Hi All,

I am having some difficulty to formate date in SAS Macro. I need your help to get this done.

%LET ASATDATE1 = &ASATDATE;

DATA _NULL_;

CALL SYMPUT('LAP_DAT_IND',%sysfunc(inputN(&ASATDATE1,DDMMYY,10)));

%PUT &LAP_DAT_IND;

RUN;

When I ran the code i am getting below error message. Could you please help me on this.

------

 

DATA _NULL_;

CALL SYMPUT('LAP_DAT_IND',%sysfunc(inputN(&ASATDATE1,DDMMYY,10)));

SYMBOLGEN: Macro variable ASATDATE1 resolves to '03-07-2013'

SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.

250 CALL SYMPUT('LAP_DAT_IND',%sysfunc(inputN(&ASATDATE1,DDMMYY,10)));

_

159

ERROR 159-185: Null parameters for SYMPUT are invalid.

 

WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.

NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set

to a missing value.

251 %put &LAP_DAT_IND &ASATDATE;

WARNING: Apparent symbolic reference LAP_DAT_IND not resolved.

SYMBOLGEN: Macro variable ASATDATE resolves to '03-07-2013'

SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.

&LAP_DAT_IND '03-07-2013'

252 RUN;

 

255 PROC SQL;

256 CREATE TABLE lapse_reg AS

257 SELECT * from people

258 WHERE person_status = '1'

259 and lapse_date < &LAP_DAT_IND;

WARNING: Apparent symbolic reference LAP_DAT_IND not resolved.

259 and lapse_date < &LAP_DAT_IND;

_

22

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,

a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.

WARNING: Apparent symbolic reference LAP_DAT_IND not resolved.

260 QUIT;

4 REPLIES 4
data_null__
Jade | Level 19

You don't need the data step and CALL SYMPUT just use %let LAP_DAT_IND=%sysfunc(inputN(&ASATDATE1,DDMMYY,10));

KannanBaskar
Calcite | Level 5

Hi ,

Thanks for your help on this. I also tried this step but unfortunately it is not working. Please find the logs below.

247        %LET  ASATDATE1 = &ASATDATE;

                                                                                                                                  

248

                                                                                                                                  

249        %LET LAP_DAT_IND2 = %sysfunc(inputN(&ASATDATE1,DDMMYY,10));

                                                                                                                                  

SYMBOLGEN:  Macro variable ASATDATE1 resolves to '03-07-2013'

                                                                                                                                  

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.               

                                                                                                                                  

WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.                    

                                                                                                                                  

NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set

      to a missing value.

                                                                                                                                  

250

                                                                                                                                  

251        PROC SQL;

                                                                                                                                  

252        CREATE TABLE lapse_reg AS

                                                                                                                                  

253        SELECT * from people

                                                                                                                                  

254        WHERE person_status = '1'

                                                                                                                                  

255        and lapse_date

                                                                                                                                  

SYMBOLGEN:  Macro variable LAP_DAT_IND2 resolves to

                                                                                                                                  

255      ! <

                                                                                                                                  

255      ! &LAP_DAT_IND2;

                                                                                                                                  

           _

                                                                                                                                  

           22

                                                                                                                                  

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,     

                                                                                                                                  

              a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.

                                                                                                                                  

                                                                                                                                  

                                                                                                                                  

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. 

data_null__
Jade | Level 19

You have quotes around the asatdate they need to be removed.

20         %LET LAP_DAT_IND = %sysfunc(inputN(%sysfunc(dequote(&ASATDATE)),mmddyy,10));
21         %put NOTE: &=asatdate &=lap_dat_ind;
NOTE: ASATDATE='03-06-2013' LAP_DAT_IND=19423
Ron_MacroMaven
Lapis Lazuli | Level 10

This page addresses your issues

http://www.sascommunity.org/wiki/Macro_Loops_with_Dates

This section has three ways of getting an integer from a data reference:

http://www.sascommunity.org/wiki/Macro_Loops_with_Dates#A_Date_is_a_Reference_to_an_Integer

Ron Fehd  macro maven

"A SAS date is an index into the associative array of dates."

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2526 views
  • 1 like
  • 3 in conversation