Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking an if-then statement using a long list of values

Status
Not open for further replies.

Chitown26

Technical User
Jul 17, 2009
1
0
0
US
Hi, everyone. Brand new to the forum. I'm writing a SAS code at work to check fields in a dataset, that uses an if statement with a long list of values. I'll write a version of my code before I go any further.

(in a data step)
if comp1 not in ('ABC' 'BMW' 'CDC' 'DOW' 'FDIC' 'HSHS' 'IKEA' 'JVC' 'KDA' ..... 'XYZ')
then comp1 = comp2;

proc freq data=comps ;
tables comp2*comp1 / list missing;
run;

Let's say that comp1 and comp2 are similar variables that take on the same values, but comp2 is just a bit more cleaned up. Is there a way to check this code in case I happen to leave out a value in the list, or someone else deletes one accidentally? Right now if 'BMW' was somehow deleted, the code would still run, but you'd possibly not even know something was wrong. Would you create a new variable in the if statement, and then perform a 3-way proc freq?
Thanks.
 
I dont understand your question. In order to check for a missing value you, the SAS programmer, need to have a list of valid values. What you describe is that another SAS programmer will tamper with your code. That you can't stop. Perhaps I am missing something???

Klaz
 
Is there a way to check this code?"

Yeah review it. How could a set of literal values be checked otherwise?

Or did I misunderstand this question?

*Ignore if this is a dead issue.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top