## Report

Solved
Super Contributor
Posts: 1,041

# 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
Posts: 3,167

## Re: Report

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

All Replies
Super Contributor
Posts: 1,041

## Re: Report

OK I found my mistake...

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
Posts: 3,167

## Re: Report

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

Super Contributor
Posts: 1,041

## 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: 6,762

## 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 and locked.