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

Hello, there is a problem with converting variables.

I got date variable "rand1" that is character and has date format(ddyymm10.) and represents as 10JUN2014(example)

I need to create new variable "rand2" and make a numeric representation of "rand1" ex - 14686(i think it's a days from 1 Jan 1960 date9. type). So, the simple code as 

 rand2 = input(rand2, 8. or date9. or whatever) makes this error 

NOTE: Invalid argument to function INPUT

Why? I don't know. There is no more errors.

Thanks in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
It should be: rand2 = input(rand, date9.);

Note that you need to name the variables different, you cannot use the same name AND if the data is wrong for some reason you'll still get that error, ie 31Sep2018 will generate an error.

View solution in original post

2 REPLIES 2
Reeza
Super User
It should be: rand2 = input(rand, date9.);

Note that you need to name the variables different, you cannot use the same name AND if the data is wrong for some reason you'll still get that error, ie 31Sep2018 will generate an error.
novinosrin
Tourmaline | Level 20

Your subject lines says numeric to character but you seem to be doing character to numeric with input reading non standard data

 

data want;
char='10JUN2014';
num_date=input(char,date9.);
*format num_date date9.;
run;

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 790 views
  • 0 likes
  • 3 in conversation