BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Stepik
Obsidian | Level 7

Dear team, I I have been stuck to find a solution to provide the output results for the 3 months. The solution does not work if I add months 04 and 05.

What is the best way to display the data for the condition WHERE Check = 0 and month = 03 04 05?

 

proc print data=Oth (obs=1000);
where Check=0 and month = 03;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

 

If month is numeric:

month in (3 4 5)

or if month is character:

 

month in ('03' '04' '05')

B.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

4 REPLIES 4
yabwon
Amethyst | Level 16

 

If month is numeric:

month in (3 4 5)

or if month is character:

 

month in ('03' '04' '05')

B.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Stepik
Obsidian | Level 7

it is numeric, so

the code is the next:

 

proc print data=Ret_oth (obs=1000);
where Check=0 and reporting_month in (03 04 05);
run;

But still the results only provide 03 data

yabwon
Amethyst | Level 16

The following:

data Ret_oth;
  do reporting_month = 1 to 5;
    Check=0; output;
    Check=1; output;
  end; 
run;

proc print data=Ret_oth (obs=1000);
where Check=0 and reporting_month in (03 04 05);
run;

works as expected.

Check you data (Maxim 3), maybe months 4 and 5 are after obs=1000?

 

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Stepik
Obsidian | Level 7
correct, I need to check for more observations. Then it works. Thanks

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1069 views
  • 1 like
  • 2 in conversation