Hi! I'm trying to find the unique identifiers that correspond to when the flag variable I made=1. I haven't been able to find a way to write a proc print of ID if flag=1? I basically want a list of the IDs when flag=1
Sample Data:
ID Flag
1 1
2 0
3 0
4 1
Enterprise Guide will not allow this:
proc print data=clean2;
where Flag=1;
run;
proc print data=have;
where flag=1;
run;
Are you seriously asking how to write a where statement in proc print?
data have;
input ID Flag ;
cards;
1 1
2 0
3 0
4 1
;
proc print;
where flag=1;
run;
No. I'm asking because I only want the ID to print (there are a dozen other variables) and this code will not run:
proc print data=clean2;
var ID;
where flag=1;
run;
or even this code:
proc print data=clean2;
where flag=1;
run;
A 'where' statement is not compatible with the proc print command.
This is in Enterprise Guide, which may be why.
What does your log say?
Both of these programs are perfectly fine, whether using EG or not. Here are some issues to look for.
Is FLAG actually a character variable? Then you would need to use:
where flag="1";
Does FLAG exist in CLEAN2 or was it created and then dropped?
Thank you, I actually just realized that for the flag variable I was running there were no flags that=1, they were all =0, therefore there was no output.
proc print data=have;
where flag=1;
run;
This code will not run in Enterprise Guide; not sure why?
Thanks, it wasn't working because there were no values of the flag variable that=1, they all =0. Still confused why the code was red but whatever.
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.