turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- IF/THEN STATEMENTS: Multiple Conditions in an Arra...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-04-2015 10:21 AM

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.

Accepted Solutions

Solution

08-04-2015
10:26 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-04-2015 10:26 AM

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.

All Replies

Solution

08-04-2015
10:26 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-04-2015 10:26 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-04-2015 10:31 AM

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!