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
(Creating a flag avoiding the If ... Then Structure)
 
(wiki gardening)
Line 2: Line 2:
  
 
Using the sashelp.Retail dataset to ilustrate how can be used this tip.
 
Using the sashelp.Retail dataset to ilustrate how can be used this tip.
 
+
<source lang="sas">
 
Data test_flags;  
 
Data test_flags;  
 
Set sashelp.retail;  
 
Set sashelp.retail;  
 
flag1 = year le 1983;
 
flag1 = year le 1983;
flag2=year=1980;
+
flag2 = year=1980;
flag3= 1981<year<1984;
+
flag3 = 1981<year<1984;
 
run;
 
run;
 
+
</source>
 
Also works with a Char variable.
 
Also works with a Char variable.
 
 
 
  
 
<noinclude>  
 
<noinclude>  
 
Data Step, Flags, SAS Base
 
Data Step, Flags, SAS Base
 
</noinclude>
 
</noinclude>
 
 
  
 
<!-- Please do not edit below this line, EXCEPT when promoting a tip -->
 
<!-- Please do not edit below this line, EXCEPT when promoting a tip -->

Revision as of 10:22, 15 August 2011

In order to build flags in a SAS datasets in a single Data Step avoiding the If ...Then structure

Using the sashelp.Retail dataset to ilustrate how can be used this tip.

Data test_flags; 
Set sashelp.retail; 
flag1 = year le 1983;
flag2 = year=1980;
flag3 = 1981<year<1984;
run;

Also works with a Char variable.


Data Step, Flags, SAS Base


Submitted By Salvador Ambrosio