Hi ,
How can i extracct the year from
1)date10. (2012-11-20)
Using substring or is there any other logic??
I want 2012
Thanks
if the value is an actual SAS date with format date10. , or actually any format,
then
year = year(datevariablename);
There are functions to pull month, day of month, day of week, quarter as well from the date values.
if the value is an actual SAS date with format date10. , or actually any format,
then
year = year(datevariablename);
There are functions to pull month, day of month, day of week, quarter as well from the date values.
Hi,
Thanks so much for the information
I have the datevariablename as numeric
when i do
year=year( datevariablename) i get year variable as charecter.How is that happening? i was expecting year variable to be numeric too since the parent was numeric
Thanks
Because you made a mistake somewhere.
Post your full code.
Hi,
DATE beow is numeric
data WANT;
set have;
year=year(DATE);
run;
Run this:
proc contents data=want;
run;
Then post the results.
Most likely, YEAR is already in your data set before you started. So you can't change it to numeric. But you could drop it:
data want;
set have (drop=year);
year = year(date);
run;
Thanks for the help. I got it. I have used put function and forgot to rerun the code
Sorry for the trouble
Now I have the year variable under which there are 2011,2010, 2012 and so on.
how can i use the proc report to get only the particular years report????
without subsetting in the original dataset
Regards
Look of the WHERE statement. It is not limited to PROC REPORT.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.