Posts

Showing posts with the label SAS Tips

Short Code Samples

1) IF-THEN-ELSE vs SELECT: The SELECT Loop Multiple IF statements in a DATA Step can be replaced with the more efficient SELECT Loop. If you would normally write: if region=' South ' then quarter=4; else if region=' North ' then quarter=3; else if region=' East ' then quarter=2; else quarter=1; You can accomplish the same thing with the SELECT Loop in a DATA Step: select (region); when (' South ') quarter=4; when (' North ') quarter=3; when (' East ') quarter=2; otherwise quarter=1; end ; source: www.usc.edu 2) IFC and IFN functions:new IF functions: IFN(condition, true-numeric-value, false-numeric-value, missing-numeric-value):IFN returns a numeric value. It returns the true, false or missing value depending on whether the condition is true, false or missing. IFC(condition, true-character-value, false-character-value, missing-character-value):IFC returns a character value. It returns the true, fals...