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

Hello,

 

I saw there are a few post about input statement errors but so far I haven't find one that solves my problem, so I am posting it here. I am doing a very basic character to numeric convert for a variable that supposed to be date value. My input data was import from CSV file.

 

Proc contents on my dataset after import as below. the variable I want to convert is

Alphabetic List of Variables and Attributes# Variable Type Len Format Informat35421

ENR_CODENum8BEST12.BEST32.
ENR_END_DATEChar10$10.$10.
ENR_START_DATENum8MMDDYY10.MMDDYY10.
PAYER_PLAN_IDChar7$7.$7.
PERSON_IDNum8BEST12.BEST32.

 

The missing values in this variables are entered as 'NI', so my first intuition is that this true character sting is preventing the conversion, so changed 'NI' to 0 then I did a simple input statement on this variable:

data test;

set pnt.oha_enro;

if ENR_END_DATE = 'NI' then ENR_end_date = '0';

run;

 

data test2;

set test;

try = input(ENR_END_DATE,8.0);

run;

 

Then I got this in the log window

data test2;

set test;

try = input(ENR_END_DATE,8.0);

run;

NOTE: Invalid argument to function INPUT at line 90 column 7.

 

Anyone has an idea why it's happening?

Thank you so much

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I am going to guess that the non "NI" values of ENR_END_DATE actually look more like the MMDDYY10. from ENR_START_DATE.

In which case you would want to 1) use the mmddyy10 informat, 2) instead of '0' assign . for missing 3) assign an appropriate format such as mmddyy10. for the new variable.

 

Or go back to the import step, copy the data step code created by proc import (assumed) from the log, paste into the editor and change the informat and format to mmyydd10. perhaps add ?? after the variable name in the input statement to suppress invalid date messages for that variable reading the data.

View solution in original post

5 REPLIES 5
Reeza
Super User

What does that variable look like? And do you have missing values? Missing would generate that error as well.

 


@LisaYIN9309 wrote:

Hello,

 

I saw there are a few post about input statement errors but so far I haven't find one that solves my problem, so I am posting it here. I am doing a very basic character to numeric convert for a variable that supposed to be date value. My input data was import from CSV file.

 

Proc contents on my dataset after import as below. the variable I want to convert is

Alphabetic List of Variables and Attributes# Variable Type Len Format Informat35421

ENR_CODE Num 8 BEST12. BEST32.
ENR_END_DATE Char 10 $10. $10.
ENR_START_DATE Num 8 MMDDYY10. MMDDYY10.
PAYER_PLAN_ID Char 7 $7. $7.
PERSON_ID Num 8 BEST12. BEST32.

 

The missing values in this variables are entered as 'NI', so my first intuition is that this true character sting is preventing the conversion, so changed 'NI' to 0 then I did a simple input statement on this variable:

data test;

set pnt.oha_enro;

if ENR_END_DATE = 'NI' then ENR_end_date = '0';

run;

 

data test2;

set test;

try = input(ENR_END_DATE,8.0);

run;

 

Then I got this in the log window

data test2;

set test;

try = input(ENR_END_DATE,8.0);

run;

NOTE: Invalid argument to function INPUT at line 90 column 7.

 

Anyone has an idea why it's happening?

Thank you so much


 

ballardw
Super User

I am going to guess that the non "NI" values of ENR_END_DATE actually look more like the MMDDYY10. from ENR_START_DATE.

In which case you would want to 1) use the mmddyy10 informat, 2) instead of '0' assign . for missing 3) assign an appropriate format such as mmddyy10. for the new variable.

 

Or go back to the import step, copy the data step code created by proc import (assumed) from the log, paste into the editor and change the informat and format to mmyydd10. perhaps add ?? after the variable name in the input statement to suppress invalid date messages for that variable reading the data.

LisaYIN9309
Obsidian | Level 7

Thanks @ballardw, I changed the 'NI' to a mmddyy10. format value instead of 0 and it worked! seems like 0 is the problem. There is no other missing values.

 

Thank you again

Kurt_Bremser
Super User

A 10-character variable with "date" in the name lets me think it will contain values like 09/04/2018, which can't be input with an 8. informat. If the values are like that, use a proper date informat.

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