Can anyone please tell me the code that will return the observations where a corresponding variable occurs more than one time within that group.
Here is my data:
Name Result
John pass
John pass
Albert
Alice fail
Julia pass
Nadia
Julia pass
Jack pass
The code will return John and Julia as both of those group has 'pass' that occurred more than one time. Output will be:
Name Result
John pass
John pass
Julia pass
Julia pass
Thank you,
Proc sort data=have out=want NOUNIQUEKEY;
by name result;
run;
Hi hai.Kuo,
My data is actually look like this:
Name Result Course
John pass Math
John pass Physics
John fail Chemistry
Albert Math
Alice fail Physics
Julia pass Physics
Nadia pass Chemistry
Julia pass Math
Jack pass Math
The code should return John and Julia as both of those group has 'pass' that occurred more than one time. Output will be:
Notice that John has 3 observations, but it discarded 'fail' and returned where there is pass within the John group.
Name Result Course
John pass Math
John pass Physics
Julia pass Physics
Julia pass Math
can you help me a bit more please.
Then add a dataset option:
Proc sort data=have(where=(result='pass')) out=want NOUNIQUEKEY;
by name result;
run;
Tested:
data have;
input (Name Result Course) (:$10.);
cards;
John pass Math
John pass Physics
John fail Chemistry
Albert . Math
Alice fail Physics
Julia pass Physics
Nadia pass Chemistry
Julia pass Math
Jack pass Math
;
Proc sort data=have(where=(result='pass')) out=want NOUNIQUEKEY;
by name result;
run;
proc print;run;
1 | John | pass | Math |
2 | John | pass | Physics |
3 | Julia | pass | Physics |
4 | Julia | pass | Math |
Hi,
I don't remember if we have a quick way to do this in Enterprise Miner. The quick alternative is to use proc sort. This would also work on a SAS Code Node in Enterprise Miner.
Personal favorite, is to use NODUP option, and by _all_. Example:
In a SAS Code in EM you might want to use
proc sort data=mydata NODUP;
by _all_;
run;
In a SAS Code Node in EM you might want to use:
proc sort data=&em_import_data out=&em_export_train NODUP;
by _all_;
run;
I hope this helps!
-Miguel
I think you are very close to what I wanted.
My data is actually look like this:
Name Result Course
John pass Math
John pass Physics
John fail Chemistry
Albert Math
Alice fail Physics
Julia pass Physics
Nadia pass Chemistry
Julia pass Math
Jack pass Math
The code should return John and Julia as both of those group has 'pass' that occurred more than one time. Output will be:
Notice that John has 3 observations, but it discarded 'fail' and returned where there is pass within the John group.
Name Result Course
John pass Math
John pass Physics
Julia pass Physics
Julia pass Math
can you help me a bit more please.
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!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.