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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statement 1

Status
Not open for further replies.

jhrBanker

Technical User
Oct 3, 2002
2
US
I'm new to SAS and having a problem with my IF statement. I'm using SAS on the mainframe and coding in JCL. I've coded my statement like this:
IF YTD LT '.00' THEN
DFND = '1' AND CNTL = '2';

In other words, if the value of YTD is LT zero, I want to populate the variable DFND with a 1 AND the variable CNTL with a 2. I've tried many different ways of writing the statement, and I either get an error message or a message stating that the second variable (CNTL) was not initialized.

1. Can someone please tell me the correct why to write this IF statement, and
2. Can you recommend a good book/source for basic SAS programming on the mainframe?

I usually program in EzTrieve.

Thanks,
 
jhrBanker, I've never actually used JCL but in SAS, if you are performing more than one action within an IF statement then you have to use DO;

Code:
IF YTD LT '.00' THEN DO;
   DFND = '1';
   CNTL = '2';
END;

Hope this helps!

Nick
 
Also, your variable YTD is probably a numeric variable. Try this:

Code:
IF YTD LT 0 THEN DO;
   DFND = '1';
   CNTL = '2';
END;

Just a note that your vars DFND and CNTL will be character variables as you are assigning chars as their values.

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top