Hi
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?
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.
Is the date a SAS date value, possibly with a yymmddn8. format? If so then the date functions would be appropriate
B_year= year(birthday);
B_Month=month(birthday);
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_month= substr(put(birthday,f8.0),5,2);
b_day = substr(put(birthday,f8.0),7,2);
it was numeric value.
Thanks~ it worked~!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.