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

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: .

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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

8 REPLIES 8
Reeza
Super User

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.

Deepti44
Fluorite | Level 6

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.);

novinosrin
Tourmaline | Level 20

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

Reeza
Super User

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


 

novinosrin
Tourmaline | Level 20

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.));

 

Deepti44
Fluorite | Level 6

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.);

ballardw
Super User

@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;
art297
Opal | Level 21

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

 

Art, CEO, AnalystFinder.com

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