MACRO variable resolving to null in batch mode and resolving to value in SAS eg

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

MACRO variable resolving to null in batch mode and resolving to value in SAS eg

Hi,

 

Im trying to  resolve a value of start_date which has a value of date value as  numeric (21032). im trying to resolve to see what date value it has , when i run %put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.); it in sas eg it is resolving to something like 28jun2017, but when i execute same code in batch mode it is resolving to null(.) see below. any idea ?

 


SYMBOLGEN: Macro variable START_DATE resolves to 21032
SYMBOLGEN: Macro variable END_DATE resolves to 21032
537
538 %put &start_date &end_date;
21032 21032
539
540 %put start_date: %sysfunc(inputn(&start_date.,worddate18.),date9.);
SYMBOLGEN: Macro variable START_DATE resolves to 21032
WARNING: Argument 2 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.
start_date: .
541 %put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.);
SYMBOLGEN: Macro variable END_DATE resolves to 21032
WARNING: Argument 2 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.
end_date: .


Accepted Solutions
Solution
2 weeks ago
PROC Star
Posts: 168

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

Yep, Thats what my understanding is too and that also raised my eyebrows failing to comprehend OP's put statements-

 

%let start_date=20133;/*i am testing*/

%let end_date=20133 /*i am testing*/

 

/*OP's put statement*/
%put start_date: %sysfunc(inputn(&start_date.,worddate18.),date9.);
%put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.);

/*my log*/

WARNING: Argument 2 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.
start_date: .
4 %put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.);
WARNING: Argument 2 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.
end_date: .

 

 

I think the correct put statement should be -

%put %sysfunc(putn(&start_date.,worddate18.));

%put %sysfunc(putn(&end_date.,worddate18.));

 

View solution in original post


All Replies
Super User
Posts: 17,792

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

What does the code submitted via batch look like?

I think running in batch, is the equivalent of running in a 'clean session' so nothing you previously created is accessible if it's not store permanently somewhere, and macro variables are not kept across sessions.

Contributor
Posts: 20

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

reeza,

 

same code below

 

PROC SQL INOBS=10;
CREATE TABLE m1 AS
SELECT A.*,input(substr(ver_desc,18,10),mmddyy10.) as date1 FROM table1  A
WHERE VER=0;
QUIT;

proc sql;
select date1 into :start_date from m1 ;
select date1 into :end_date from m1 ;
quit;

%put &start_date &end_date;

%put start_date: %sysfunc(inputn(&start_date.,worddate18.),date9.);
%put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.);

PROC Star
Posts: 168

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

[ Edited ]

Hi, is inputn necessary to read a number which is not a formtted date value/character value? Or am i missing something

 

%put %sysfunc(putn(21033,date9.));

 

I am wondering how can a worddate18. informat be used to read 21033

Super User
Posts: 17,792

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

INFORMAT represents the data the format is already in and you want to read it in. 

FORMAT is how you want to display the information.

 


novinosrin wrote:

Hi, is inputn necessary to read a number which is not a formtted date value/character value? Or am i missing something

 

%put %sysfunc(putn(21033,date9.));

 

I am wondering how can a worddate18. informat be used to read 21033


 

Solution
2 weeks ago
PROC Star
Posts: 168

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

Yep, Thats what my understanding is too and that also raised my eyebrows failing to comprehend OP's put statements-

 

%let start_date=20133;/*i am testing*/

%let end_date=20133 /*i am testing*/

 

/*OP's put statement*/
%put start_date: %sysfunc(inputn(&start_date.,worddate18.),date9.);
%put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.);

/*my log*/

WARNING: Argument 2 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.
start_date: .
4 %put end_date: %sysfunc(inputn(&end_date.,worddate18.),date9.);
WARNING: Argument 2 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.
end_date: .

 

 

I think the correct put statement should be -

%put %sysfunc(putn(&start_date.,worddate18.));

%put %sysfunc(putn(&end_date.,worddate18.));

 

Contributor
Posts: 20

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

Thank you.

 

but only my question is when i run below statement in sas eg it is displaying date9 something like "28jun2017" ? not sure y.

 

%put start_date: %sysfunc(inputn(&start_date.,worddate18.),date9.);

Super User
Posts: 10,490

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg


Deepti44 wrote:

Thank you.

 

but only my question is when i run below statement in sas eg it is displaying date9 something like "28jun2017" ? not sure y.

 

%put start_date: %sysfunc(inputn(&start_date.,worddate18.),date9.);


Please show the value you are using for &start_date.

 

And I would expect that to generate an error as WORDATE. is not an informat that can be used with input

11   data junk;
12      y=input('January 1, 2017', Worddate18.);
                                   -----------
                                   485
NOTE 485-185: Informat WORDDATE was not found or could not be loaded.

13   run;
PROC Star
Posts: 7,362

Re: MACRO variable resolving to null in batch mode and resolving to value in SAS eg

My guess is that when you're running in batch mode you haven't created table1 in your work directory.

 

Art, CEO, AnalystFinder.com

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 179 views
  • 0 likes
  • 5 in conversation