Hello everyone,
I am trying to create a summary score based on eight dichotomous variables (labelled 1/2 instead of 0/1 since I am going to be doing my regression analysis in SUDAAN). Each of the variables has missing values and I would like my array to show that IF there are more than four missing values between the eight variables for a single observation THEN the observation is read as missing. Otherwise, if there are less than four missing values between the eight variables, then the score will be between 1-8.
This is what my array looks like at the moment (a shoutout to PhilC for helping fix my array) and it works for giving me a sum score between 1-8.
ARRAY ACE_ARRAY[8] ACEPRISN2 ACEDIVRC2 ACEDEPRS2 ACESXAB ACESUBS ACEPUNCH2 ACESWEAR2 ACEHURT2;
SUM_ACESCORE = 0;
do i=1 to 8; drop i;
SUM_ACESCORE+ACE_ARRAY;
end;
I assume you can use some type of IF/THEN statement in the DO loop to do this, but I cannot figure out how to signify "four or more missing values".
As always Thank you guys for your help!
Donald S.
Hi,
Correction, use the nmiss() function
ARRAY ACE_ARRAY[8] ACEPRISN2 ACEDIVRC2 ACEDEPRS2 ACESXAB ACESUBS ACEPUNCH2 ACESWEAR2 ACEHURT2;
SUM_ACESCORE = 0;
do i=1 to 8; drop i;
if nmiss(of ace_array{*})<4 then SUM_ACESCORE+ACE_ARRAY;
end;
Also, try to use lower case in SAS code.
Hi,
Correction, use the nmiss() function
ARRAY ACE_ARRAY[8] ACEPRISN2 ACEDIVRC2 ACEDEPRS2 ACESXAB ACESUBS ACEPUNCH2 ACESWEAR2 ACEHURT2;
SUM_ACESCORE = 0;
do i=1 to 8; drop i;
if nmiss(of ace_array{*})<4 then SUM_ACESCORE+ACE_ARRAY;
end;
Also, try to use lower case in SAS code.
Worked like a charm! Thank you RW9.
I feel like every time someone helps me figure out a problem on here I learn something new and very useful!
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.