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: 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!

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.

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