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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.