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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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