Please pen down a small sample like i did with 5 or 6 records and post the output you want. Then using that you can test against the real dataset you have
@Flexluthorella wrote:
"Using the data sets Demodemo.sas7bdat and Visitdemo.sas7bdat, we want to create a cohortcontaining patients whose minimum body weight prior to ART start is more than 10 poundsless than their maximum body weight after ART start and compare the proportion of deceased men to deceased women in this cohort."I will be honest, I may not full understand the question and my professor is not responding to me.patient_Id Male death arvstart apptdate1 1 1 12May2012 01june201212 0 1 05april2015 09aug201636 1 0 18jan2016 06feb2013
So you must have other data with WEIGHT and another DATE variable (or is the APPTDATE variable the date that the weight was recorded?). Either those variables are in that table or in another table (that also has PATIENT_ID) that you will need to join/merge with the patient level data you are showing so that you can compare the dates.
First you need to decide whether weight values collected on ARVSTART are to be include in the BEFORE or AFTER group (or perhaps neither). Then find the MIN for those BEFORE and the MAX for those after and subtract. So that you can get something like:
patient_Id Male death MIN_BEFORE MAX_AFTER GAIN 1 1 1 200 250 50 12 0 1 100 105 5 36 1 0 180 175 -5
Now you can make a binary variable by checking the GAIN value and seeing if it greater than 10. So only patient 1 in this dummy data.
Once you have that you then want to find subset to just those cases and compare the death rate in the males and females (not males?).
Split into 2 summaries (before and after arvstart)
Merge and compare min_wt and max_wt.
proc means nway missing noprint data=have(where=(apptdate le arvstart));
class patient_id male death;
output out=before(drop=_type_ _freq_)
min(weight)=min_wt;
run;
proc means nway missing noprint data=have(where=(apptdate gt arvstart));
class patient_id male death;
output out=after(drop=_type_ _freq_)
max(weight)=max_wt;
run;
data want;
merge before(in=a) after(in=b);
by patient_id male death;
if a and b;
if max_wt - min_wt gt 10;
run;
-unison
output out=minweight min= / autoname ;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.