<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding Variables to data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605272#M175636</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if breed in ("Bulldog", "Lab", "Terrier", "Shepherd", "Beagle") then&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use the IN operator&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _aac_new_variable; 

set dog_data;

if breed in ( "Bulldog", "Lab", "Terrier", "Shepherd", "Beagle") then Topbreed = 1;

else = 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Nov 2019 02:15:03 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-11-19T02:15:03Z</dc:date>
    <item>
      <title>Adding Variables to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605270#M175634</link>
      <description>&lt;P&gt;Attempting to create new variable top breed based on dog data set. Trying to set top breed to 1 if the breed contains the words in the if statement , and 0 if not. Currently code is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data_aac_new_variable;&lt;/P&gt;&lt;P&gt;set = dog_data;&lt;/P&gt;&lt;P&gt;if breed = "Bulldog", "Lab", "Terrier", "Shepherd", "Beagle" then Topbreed = 1;&lt;/P&gt;&lt;P&gt;else = 0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 01:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605270#M175634</guid>
      <dc:creator>cpmcn19</dc:creator>
      <dc:date>2019-11-19T01:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605272#M175636</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if breed in ("Bulldog", "Lab", "Terrier", "Shepherd", "Beagle") then&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use the IN operator&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _aac_new_variable; 

set dog_data;

if breed in ( "Bulldog", "Lab", "Terrier", "Shepherd", "Beagle") then Topbreed = 1;

else = 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 02:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605272#M175636</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-19T02:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605273#M175637</link>
      <description>&lt;P&gt;Few Issues With the code corrected:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data_aac_new_variable;

set  dog_data;

if breed  in ("Bulldog", "Lab", "Terrier", "Shepherd", "Beagle" ) then Topbreed = 1;

else Topbreed = 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;data_aac_new_variable;

&lt;FONT color="#993300"&gt;&lt;STRIKE&gt;set = dog_data;&lt;/STRIKE&gt;&lt;/FONT&gt;
if breed &lt;FONT color="#993300"&gt;&lt;STRIKE&gt;= "Bulldog", "Lab", "Terrier", "Shepherd", "Beagle" then Topbreed = 1;&lt;/STRIKE&gt;
&lt;STRIKE&gt;else = 0;&lt;/STRIKE&gt;&lt;/FONT&gt;

run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 02:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605273#M175637</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-11-19T02:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605275#M175638</link>
      <description>&lt;P&gt;Thanks for the reply. Is there anyway to add a contains to the if breed in statement? Some data says Lab whereas other data says Labrador&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 02:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605275#M175638</guid>
      <dc:creator>cpmcn19</dc:creator>
      <dc:date>2019-11-19T02:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605278#M175640</link>
      <description>&lt;P&gt;Try :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _aac_new_variable;

set  dog_data;

if breed  in ("Bulldog",  "Terrier", "Shepherd", "Beagle" ) or breed =:'Lab' then Topbreed = 1;

else Topbreed = 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 02:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605278#M175640</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-11-19T02:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605279#M175641</link>
      <description>&lt;P&gt;You can reduce this to one statement if you use a Boolean expression:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Topbreed = (if breed in ("Bulldog", "Terrier", "Shepherd", "Beagle" ) or breed =:'Lab');
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 02:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-data-set/m-p/605279#M175641</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-11-19T02:48:33Z</dc:date>
    </item>
  </channel>
</rss>

