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

Hello I have this variable Hosp_adm which I want to convert to nummeric. 

 

The data is below:

SAS Output

Obs Hosp_adm
1 25JUL2016
2 27JUL2016
3 27JUL2016
4 11JUL2016
5 28JUL2016
6 29JUL2016
7 29JUL2016
8 29JUL2016
9 31JUL2016
10 28JUL2016

 

 

data baseline;
set baseline;
new_Hosp_adm=input(Hosp_adm, date9.);
format new_Hosp_adm date9.;
run;

 

Please can anyone correct the code for me???

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Your code looks correct as is.  What happens when you run it?

 

Did you run a PROC CONTENTS to verify that this hasn't already been done?  Maybe HOSP_ADM is already numeric, with a DATE9 format used for printing.

View solution in original post

3 REPLIES 3
Astounding
PROC Star

Your code looks correct as is.  What happens when you run it?

 

Did you run a PROC CONTENTS to verify that this hasn't already been done?  Maybe HOSP_ADM is already numeric, with a DATE9 format used for printing.

DWarner
SAS Employee

SAS stores calendar dates as numeric values. That is, a date is stored as a value that represents the number of days since the calendar date January 1, 1960. For example, the value for January 1, 1960 is 0. The value for January 1, 1961 is 366. SAS converts date values back and forth between calendar dates with SAS informats and formats. If you do a PROC CONTENTS on your data set, you will probably see that the variable is a numeric with an informat applied to it. You should be able to perform calculations on the column.  

desireatem
Pyrite | Level 9

Thank you!!!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 36540 views
  • 0 likes
  • 3 in conversation