As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Tips:Creating a flag avoiding the If ... Then Structure"

From sasCommunity
Jump to: navigation, search
m (Notables say it is ready (Art Carpenter and Don Henderson) Promoted to READY.)
(linked to relevant IF statement subsection)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
When building binary flags in a SAS DATA Step you can avoid the IF-THEN/ELSE structure such as:
+
When building binary flags in a [[SAS]] [[DATA Step]] you can avoid the [[IF statement#IF THEN ELSE statement|IF-THEN/ELSE structure]] such as:
 
<source lang="sas">
 
<source lang="sas">
 
IF MIN(x , y) GT 4 THEN flag = 1 ;
 
IF MIN(x , y) GT 4 THEN flag = 1 ;
 
                   ELSE flag = 0 ;
 
                   ELSE flag = 0 ;
 
</source>
 
</source>
by using alternate statement forms:
+
by using alternate [[statement]] forms:
 
<source lang="sas">
 
<source lang="sas">
 
flag = MIN(x , y) GT 4 ;
 
flag = MIN(x , y) GT 4 ;
Line 12: Line 12:
 
flag = IFN(MIN(x , y) GT 4 , 1 , 0) ;
 
flag = IFN(MIN(x , y) GT 4 , 1 , 0) ;
 
</source>
 
</source>
<noinclude>
 
[[Category:DATA Step]]
 
[[Category:IF-THEN/ELSE Statement]]
 
[[Category:IFN Function]]
 
[[Category:MIN Function]]
 
</noinclude>
 
  
 
{{ExternalReadMore|http://www.pharmasug.org/proceedings/2013/BB/PharmaSUG-2013-BB03.pdf}}
 
{{ExternalReadMore|http://www.pharmasug.org/proceedings/2013/BB/PharmaSUG-2013-BB03.pdf}}
Line 24: Line 18:
 
<!-- Please do not edit below this line, EXCEPT when promoting a tip -->
 
<!-- Please do not edit below this line, EXCEPT when promoting a tip -->
 
<div style="float:right">Submitted By Salvador Ambrosio</div>
 
<div style="float:right">Submitted By Salvador Ambrosio</div>
 +
 
<noinclude>
 
<noinclude>
[[Category:Tip Ready]]
+
[[Category:DATA Step]]
 +
[[Category:IF-THEN/ELSE Statement]]
 +
[[Category:IFN Function]]
 +
[[Category:MIN Function]]
 +
[[Category:Tip in Use]]
 
</noinclude>
 
</noinclude>

Latest revision as of 17:11, 17 July 2017

When building binary flags in a SAS DATA Step you can avoid the IF-THEN/ELSE structure such as:

IF MIN(x , y) GT 4 THEN flag = 1 ;
                   ELSE flag = 0 ;

by using alternate statement forms:

flag = MIN(x , y) GT 4 ;

or

flag = IFN(MIN(x , y) GT 4 , 1 , 0) ;

....see also

....read more

Submitted By Salvador Ambrosio