BookmarkSubscribeRSS Feed
anandmgjsa
Fluorite | Level 6

Hi,

 

data report_week_oct_dec_data;

set report_04_01_2021(In = in1)

     report_11_01_2021(In = in2) 

     report_18_01_2021(rename = (date = chardate))

     report_25_01_2021(rename = (date = chardate))

     report_28_12_2020(rename = (date = chardate));

if not missing (chardate) then date = input(chardate,yymmdd10.);

if in1 or in2 then date = input(put(date,f8.),yymmdd10.);

format date yymmdd10.;

run;

the datatype of date in the 1st two data sets it is best32. and in the last 3 datasets it char10.

 

After running this code, the date column is coming blank.

As I have been running the code on VDI, I am not privilleged to copy/snip the log.

However, I am writing the log for this part of code.

Note : Invalid argument to function input at line 476 column 176.

In1=1 In2=0 date=. ccsid = 1134567  chardate= _Error_ =1 _N_=20

 

Please help!

8 REPLIES 8
ballardw
Super User

@anandmgjsa wrote:

hi,

 

data report_week_oct_dec_data;

set report_04_01_2021(In = in1)

     report_11_01_2021(In = in2) 

     report_18_01_2021(rename = (date = chardate))

     report_25_01_2021(rename = (date = chardate))

     report_28_12_2020(rename = (date = chardate));

if not missing (chardate) then date = input(chardate,yymmdd10.);

if in1 or in2 then date = input(put(date,f8.),yymmdd10.);

format date yymmdd10.;

run;

the datatype of date in the 1st two data sets it is best32. and in the last 3 datasets it char10.

 

After running this code, the date column is coming blank.

As I have been running the code on VDI, I am not privilleged to copy/snip the log.

However, I am writing the log for this part of code.

Note : Invalid argument to function input at line 476 column 176.

In1=1 In2=0 date=. ccsid = 1134567  chardate= _Error_ =1 _N_=20

 

Please help!


So you have to 1) type out line 476 from your log.

Since you say the problem is occurring at column 176 and not of the lines you show for code exceed 80 characters or so then your "code" is different.

 

The issue is you have  invalid data: date is missing from your data set indicated by IN1 in this case. If there is nothing in the INPUT data set what do expect for output. You can address that by:

 

if (in1 or in2) and not missing(date) then date = input(put(date,f8.),yymmdd10.);

 

But that would only effect one record in the output data set, or any of the records from the contributing data sets. If ALL of the column is blank then I strongly suggest you go back and examine ALL the records of your data sets.

 

Can you create TEXT files from SAS code? PROC PRINTO will allow you to direct the LOG to a file. The you could attach the text file to a message with actual details.

anandmgjsa
Fluorite | Level 6

after that it is written in the log:

chardate =2020-10-22    ccsid =    date=2020-10-22

ballardw
Super User

@anandmgjsa wrote:

after that it is written in the log:

chardate =2020-10-22    ccsid =    date=2020-10-22


Hens teeth.

Pulling.

 

One line at at time without much context isn't really helping much.

Look into Proc Printo for creating a text file of what is written to the log. Then attach the generated text file in the forum.

anandmgjsa
Fluorite | Level 6

I don't have internet connection in my VDI.

I am just seeing it i typing it in my own environment which has connectivity.

so, I can not send the log.

Kurt_Bremser
Super User

And if this is necessary:

date = input(put(date,f8.),yymmdd10.);

then your whole data import process is broken, as date values should have been read as such (and not as 8-digit numbers) in the first place.

If have a strong suspicion that all your woes are caused by the use of PROC IMPORT.

Please let us know how the data arrives in SAS.

anandmgjsa
Fluorite | Level 6

I have imported all the excel files from import data option of File in menu bar.

Then, I have triggered "run import data".

I have not used proc iport beacause it's not working in my system due to configuration issues of my SAS EG. 

Kurt_Bremser
Super User
In1=1 In2=0 date=. ccsid = 1134567  chardate= _Error_ =1 _N_=20

This shows us that

  • you are reading from the first dataset
  • date is missing
  • put(date,f8.) will create a string with a single dot in it
  • which is an invalid value for the YYMMDD10. informat.

Change your statement to

if (in1 or in2) and not missing(date) then date = input(put(date,f8.),yymmdd10.);

Given that you use the import task for Excel files (which is just as bad as using PROC IMPORT, as it also involves guessing by a few grams of silicone, and I sincerely hope that you do not consider that few grams of silicone to be more intelligent than yourself), you will get all kinds of funny artifacts when doing this repeatedly.

I suggest that you

  • export the Excel spreadsheets to csv files
  • copy those to your server with the Copy Files task
  • and run the same, user-written data step to read those csv's

this will give you consistent variable attributes throughout. If you encounter interesting input (like "N/A" for missing numeric values), you can take care of that in the code with custom-made informats.

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