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
Opal | Level 21

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
Opal | Level 21

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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