BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
novinosrin
Tourmaline | Level 20

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
Obsidian | Level 7
"Using the data sets Demodemo.sas7bdat and Visitdemo.sas7bdat, we want to create a cohort
containing patients whose minimum body weight prior to ART start is more than 10 pounds
less 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              apptdate
1               1        1    12May2012          01june2012
12             0         1    05april2015          09aug2016
36             1         0     18jan2016            06feb2013
 
 
Tom
Super User Tom
Super User

@Flexluthorella wrote:
"Using the data sets Demodemo.sas7bdat and Visitdemo.sas7bdat, we want to create a cohort
containing patients whose minimum body weight prior to ART start is more than 10 pounds
less 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              apptdate
1               1        1    12May2012          01june2012
12             0         1    05april2015          09aug2016
36             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?).

unison
Lapis Lazuli | Level 10

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

-unison
Flexluthorella
Obsidian | Level 7
Thank you you all so much for your help! This is a very nice community. I really appreciate your help and patience with a young and new programmer like myself 🙂
Flexluthorella
Obsidian | Level 7
the proc sql function did not work. error states that state is not valid or used out of proper order.
Flexluthorella
Obsidian | Level 7
I designated the name as minWt. If I did autoname, how would that help with carrying over the other variables.?

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 22 replies
  • 1870 views
  • 1 like
  • 6 in conversation