06-06-2013 11:34 AM
I have my own dataset as follows
Now Birthday is like yyyymmdd (e.g. 20011011)
and I want to make it seperately like
B_Year B_Month B_Day
2001 10 11
But, how can I do this?
I tried to make it using substr function but, it doesn't work.
maybe because it is numeric format or somehing. but, Is there any way that I can extract it separtely?
06-06-2013 12:18 PM
You'll have to tell us more about the variable BIRTHDAY.
Is it character or numeric?
If numeric, does it actually take on the value that you have displayed, or is that a formatted value based on the scale that SAS normally uses for dates?
Once we know those answers, the programming will be easy.
06-06-2013 12:24 PM
Is the date a SAS date value, possibly with a yymmddn8. format? If so then the date functions would be appropriate
B_Day = day(birthday).
if you want a text result and the birthday is a simple number then something like this may work:
b_year = substr(put(birthday,f8.0),1,4);
b_day = substr(put(birthday,f8.0),7,2);