Morning SAS Experts,
I am wondering if anyone would be willing to to guide me towards the correct steps to take. What I would like to do is look only at users who took Drug A after enrollment (I do not have a specific variable for this) but I do have a list of all subject ID numbers of those who have taken Drug A after enrollment.
Essentially, I would like to use these subject numbers (N=15) in order to conduct separate analyses on this group of individuals only.
I am not sure if I should generate new variable or use a series of if or then statements or if there is another way to do this.
Any recommendations would be greatly appreciated.
Thank you,
T.
Just add a WHERE statement to your analysis, you can use the IN operator to test if the value in one of a list of values.
So if the subject id numbers are in the character variable ID (why would an identifier by a numeric variable) then you just need something like:
proc means data=have ;
where id in ('101','203','405');
var age ht wt;
run;
You could probably type the ID numbers in, but I suspect that these 15 IDs are already in some text file or spreadsheet or database or other electronic form. If that's the case, then read the text file or spreadsheet or database table and use that information to help you segregate the data to do the analysis you want.
Just add a WHERE statement to your analysis, you can use the IN operator to test if the value in one of a list of values.
So if the subject id numbers are in the character variable ID (why would an identifier by a numeric variable) then you just need something like:
proc means data=have ;
where id in ('101','203','405');
var age ht wt;
run;
This did the trick - thank you very much. I just modified it to be for Tables/frequency as opposed to means.
Thanks again.
T.
Assumptions:
proc sql;
create table want as
select * from have
where ID in (Select ID from SELECTED);
quit;
This works regardless if ID's are duplicated in the HAVE or SELECTED cases.
If IDs are not duplicated in any data set another method is:
proc sort data=have;
by ID;
proc sort data=selected;
by ID;
data want;
merge have selected(in=sel);
by ID;
if sel;
run;
@SAS_Novice22 wrote:
Morning SAS Experts,
I am wondering if anyone would be willing to to guide me towards the correct steps to take. What I would like to do is look only at users who took Drug A after enrollment (I do not have a specific variable for this) but I do have a list of all subject ID numbers of those who have taken Drug A after enrollment.
Essentially, I would like to use these subject numbers (N=15) in order to conduct separate analyses on this group of individuals only.
I am not sure if I should generate new variable or use a series of if or then statements or if there is another way to do this.
Any recommendations would be greatly appreciated.
Thank you,
T.
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 16. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.