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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

daszlosek
Quartz | Level 8

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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 931 views
  • 0 likes
  • 2 in conversation