BookmarkSubscribeRSS Feed
Red_Squirrel
Calcite | Level 5

o

Hello,

I have and Excel file that I'm reading into SAS.

One of the columns has got the mix of dates and N/A values.

I'm trying to write this into SAS format of ddmmyy10.0.


That's  what I have so far in my code:


if x = 'N/A' then y = .;

else y = input (strip(x), ddmmyy10.0);


format y ddmmyy10.0;


this returns me the error message:

Invalid argument to function INPUT at line....


can can you please advise what needs to be done to correct the issue?

5 REPLIES 5
Astounding
PROC Star

You have an extra "0" in your code.  10.0 is a valid format/informat to indicate one position after the decimal point.  But dates don't have positions after the decimal point, so switch to ddmmyy10. instead of ddmmyy10.0.

Good luck.

Red_Squirrel
Calcite | Level 5

Thanks, Aastounding.

i Changed this previously as well however I still get the same error message.

data_null__
Jade | Level 19

I don't think the .0 is the problem.

data _null_;
  
x = input('10-10-15',ddmmyy10.0);
   put x=date9.;
  
run;

23         data _null_;
24            x = input('10-10-15',ddmmyy10.0);
25            put x=date9.;
26            run;

x=10OCT2015
NOTE: DATA statement used (Total process time):
      real time          
0.00 seconds
      cpu time           
0.00 seconds
Red_Squirrel
Calcite | Level 5

Thank You all for the valuable contributions.

None of the suggestions helped unfortunately.

I think that's due to the very poor quality level of data in the Excel file.

As I am not able to influence production of this file I decided to chang the code logic and get rid of this particular data transformation altogether.

Thank you!

ballardw
Super User

Also look at the values of X. Depending on how you moved the data from Excel to SAS you may have values like "41950" which would not be valid for reading using almost any informat available. Search the formun for Excel date values and you'll find several discussions on this topic.

Unless you have a whole bunch of files to process I would be very tempted to go back and save the Excel to CSV format and then import that. You may have better luck as you can modify Proc Import generated code to set variable informats and have better control. Reading the date values with a date informat will then turn any of the N/A values to missing at read.

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