Help using Base SAS procedures

Experts: how to efficiently use the statement of ' if a in ( , , , , )'

Reply
Occasional Contributor
Posts: 18

Experts: how to efficiently use the statement of ' if a in ( , , , , )'

Experts:

I have a list of 200+values in ( , , , ,). If I list them all, it is too much work especially, when I have to use the same statement several times.

Please advise. Thank you very much. Message was edited by: tulip
Super Contributor
Super Contributor
Posts: 3,174

Re: Experts: how to efficiently use the statement of ' if a in ( , , , , )'

How/where is the list stored? If the list is in a SAS dataset, you can generate SAS code using PROC SQL and build a set of SAS macro variables. Then use those macro variables within a SAS macro to generate other code.

Another technique is referenced in the technical paper below, found at the SAS support website using a Google advanced search argument.

Scott Barry
SBBWorks, Inc.

A Sample Macro for Creating a List on the Fly
Debbie Miller, National Park Service, Denver, CO
http://www2.sas.com/proceedings/sugi30/030-30.pdf


Using the Magical Keyword "INTO:" in PROC SQL
http://www2.sas.com/proceedings/sugi27/p071-27.pdf
Super Contributor
Super Contributor
Posts: 3,174

Re: Experts: how to efficiently use the statement of ' if a in ( , , , , )'

Also consider an alternative which would be using a PROC FORMAT and a DATA step PUT function to do look-ups or for finding match conditions against your list. With such a large list of values, you will likely find the performance to be better using PUT function. And, a DATA step MERGE (or PROC SQL JOIN) to match values against your list may also be a suitable.

Scott Barry
SBBWorks, Inc.
Occasional Contributor
Posts: 18

Re: Experts: how to efficiently use the statement of ' if a in ( , , , , )'

Thank you very much. I will try that.
Ask a Question
Discussion stats
  • 3 replies
  • 97 views
  • 0 likes
  • 2 in conversation