BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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

View solution in original post

4 REPLIES 4
robertrao
Quartz | Level 8

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

Haikuo
Onyx | Level 15

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

robertrao
Quartz | Level 8

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

Astounding
PROC Star

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.

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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