Help using Base SAS procedures

Report

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

Report

I have year variable under which there are many different years

I want to do a report on this dataset and  for each year seperately

since year is numeric i cannot use it in the where statement inside the PROC REPORT

when i convert to charecter in the datastep and then use it in the where statement inside the report it says :there were 0 observations where year is 2011

Could you tell me where i went wrong??

YEAR

2011

2011

2010

2012

Thanks


Accepted Solutions
Solution
‎05-29-2013 03:09 PM
Respected Advisor
Posts: 3,124

Re: Report

year=put(year(date),4.);

View solution in original post


All Replies
Super Contributor
Posts: 1,040

Re: Report

OK I found my mistake...

There were some leading spaces

Could someone help me do all the three things together while extracting year from the date variable????

year=year(date);

year1=put(year,best.);

year2=strip(year1);

Thanks

Solution
‎05-29-2013 03:09 PM
Respected Advisor
Posts: 3,124

Re: Report

year=put(year(date),4.);

Super Contributor
Posts: 1,040

Re: Report

Hi,

Instead of the 4. if i used best. I am getting leading spaces. Why is that? and could you also show me how to strip in the same line

Is the below one right ??

year=strip(put(year(date),4.));

Thanks

Super User
Posts: 5,082

Re: Report

You're making your life way too complicated.  Of course you can use a WHERE statement on a numeric variable:

where numvar=2011;

Just don't use quotes when referring to a numeric value.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 179 views
  • 0 likes
  • 3 in conversation