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
- /
- Base SAS Programming
- /
- Check for special values in numbered range lists

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

04-02-2014 03:34 AM

Hi everyone,

I've used numbered range lists to input variables and to check them for missing values, which worked quite well: **If nmiss(of a1-a3 b1-b3)>0 Then...**

Now, I need to also check if any of the variables is zero. Therefore, I enhanced the If-clause accordingly: **If nmiss(of a1-a3 b1-b3)>0 or min(of a1-a3 b1-b3)=0 Then...**

Interestingly, this slows down processing time considerably (on my machine for >60 variables). Although I can live with that, I wonder if there's a better approach.

Data zzz;

Input a1-a3 b1-b3;

If nmiss(of a1-a3 b1-b3)=0 And min(of a1-a3 b1-b3)>0 Then Output;

Datalines;

1 2 3 4 5 6

1 . 3 4 5 6

1 2 3 4 0 6

;

Run;

Accepted Solutions

Solution

04-02-2014
05:28 AM

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

Posted in reply to Georg_UPB

04-02-2014 05:27 AM

Not sure if it makes any difference, but you may try to replace two functions with only one "ORDINAL",

**Data** zzz;

Input a1-a3 b1-b3;

/* If nmiss(of a1-a3 b1-b3)=0 And min(of a1-a3 b1-b3)>0;*/

if ordinal(1,of a1-a3 b1-b3) >**0**;

Datalines;

1 2 3 4 5 6

1 . 3 4 5 6

1 2 3 4 0 6

;

**Run**;

Haikuo

All Replies

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

Posted in reply to Georg_UPB

04-02-2014 04:53 AM

You could consider normalizing your data, so something like:

Section Type Value

1 A1 1

1 A2 2

...

3 B3 6

Then you could use SQL to sum and find missing values. This may help with performance, however the secondary benefit of this is scalability. So you have >60 variables at the moment, this is 60 rows per group, however what about 120, or more. As for your example, I couldn't see any way of speeding it up other than that.

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

Posted in reply to Georg_UPB

04-02-2014 05:04 AM

If your source data is in SAS tables, and if you want to subset your data with this condition, use WHERE instead,

Otherwise, I can't see any real alternative. Syntactically you could use an array instead, but it's very unlikely that it could be more efficient than built-in functions.

Data never sleeps

Solution

04-02-2014
05:28 AM

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

Posted in reply to Georg_UPB

04-02-2014 05:27 AM

Not sure if it makes any difference, but you may try to replace two functions with only one "ORDINAL",

**Data** zzz;

Input a1-a3 b1-b3;

/* If nmiss(of a1-a3 b1-b3)=0 And min(of a1-a3 b1-b3)>0;*/

if ordinal(1,of a1-a3 b1-b3) >**0**;

Datalines;

1 2 3 4 5 6

1 . 3 4 5 6

1 2 3 4 0 6

;

**Run**;

Haikuo

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

Posted in reply to Georg_UPB

04-02-2014 05:38 AM

Maybe it will be a bit faster if you split the expressions into two subsetting IFs. This way MIN is only executed for observations that have no missing values.

Input a1-a3 b1-b3;

If nmiss(of a1-a3 b1-b3) eq

if min(of a1-a3 b1-b3) gt

Datalines;

1 2 3 4 5 6

1 . 3 4 5 6

1 2 3 4 0 6

;;;;