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???
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.
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.
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.
Thank you!!!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.