<?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: Create a new variable based on two variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175249#M44976</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;format RaceAndEthnicity $ 20.;&lt;/P&gt;&lt;P&gt;If Ethnicity= 1 then RaceAndEthnicity = "Hispanic - Any Race";&lt;/P&gt;&lt;P&gt;Else If Ethnicity= 2 and Race = "White" then RaceAndEthnicity = "White NH";&lt;/P&gt;&lt;P&gt;Else If Ethnicity= 2 and Race in ("Black", "African American") then RaceAndEthnicity = "Black NH";&lt;/P&gt;&lt;P&gt;Else If Ethnicity= 2 and Race = "Asian/Native Hawaiian or Other Pacific Islander" then RaceAndEthnicity = "Asian";&lt;/P&gt;&lt;P&gt;Else RaceAndEthnicity = "Others/Unknown";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jan 2015 18:23:27 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2015-01-08T18:23:27Z</dc:date>
    <item>
      <title>Create a new variable based on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175248#M44975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to create a new variable( RaceEthnicity)&amp;nbsp; based on these two variables (Race and Ethnicity):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="74" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="border: 1px solid rgb(0, 0, 0); width: 731px; height: 74px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Race&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Ethnicity&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;American Indian or Alaska Native&lt;/P&gt;&lt;P&gt;Asian/Native Hawaiian or Other Pacific Islander&lt;/P&gt;&lt;P&gt;Bi-racial&lt;/P&gt;&lt;P&gt;Black or African American&lt;/P&gt;&lt;P&gt;Other&lt;/P&gt;&lt;P&gt;Unknown&lt;/P&gt;&lt;P&gt;White&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;'1'='HISPANIC'&lt;/P&gt;&lt;P&gt;'2'='NOT HISPANIC '&lt;/P&gt;&lt;P&gt;'9'='UNKNOWN&lt;/P&gt;&lt;P&gt;'7'=UNKNOWN&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;I &lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I want new variable ( RaceEthnicity) to have 5 categories &lt;/SPAN&gt;based&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; on these conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If Ethnicity= '1' and Race =Any then RaceAndEthnicity = Hispanic- Any Race&lt;/P&gt;&lt;P&gt;If Ethnicity= '2' and Race =White then RaceAndEthnicity = White NH&lt;/P&gt;&lt;P&gt;If Ethnicity= '2' and Race =Black or African American then RaceAndEthnicity = Black NH&lt;/P&gt;&lt;P&gt;If Ethnicity= '2' and Race = Asian/Native Hawaiian or Other Pacific Islander then RaceAndEthnicity = Asian&lt;/P&gt;&lt;P&gt;Any other combination= Others/Unknown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What will be best way to do it (preferably in single step)? Any suggestion will be appreciated?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 18:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175248#M44975</guid>
      <dc:creator>bikash</dc:creator>
      <dc:date>2015-01-08T18:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175249#M44976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;format RaceAndEthnicity $ 20.;&lt;/P&gt;&lt;P&gt;If Ethnicity= 1 then RaceAndEthnicity = "Hispanic - Any Race";&lt;/P&gt;&lt;P&gt;Else If Ethnicity= 2 and Race = "White" then RaceAndEthnicity = "White NH";&lt;/P&gt;&lt;P&gt;Else If Ethnicity= 2 and Race in ("Black", "African American") then RaceAndEthnicity = "Black NH";&lt;/P&gt;&lt;P&gt;Else If Ethnicity= 2 and Race = "Asian/Native Hawaiian or Other Pacific Islander" then RaceAndEthnicity = "Asian";&lt;/P&gt;&lt;P&gt;Else RaceAndEthnicity = "Others/Unknown";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 18:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175249#M44976</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-01-08T18:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175250#M44977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohamed,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Code ran but I can only see '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Hispanic - Any Race' and 'Others/Unknown' in my result. Looks like only &lt;/SPAN&gt;first&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; and last line were &lt;/SPAN&gt;recognized&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; by SAS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;See log below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Variable Ehtnic is uninitialized.&lt;/P&gt;&lt;P&gt;NOTE: Variable Race is uninitialized.&lt;/P&gt;&lt;P&gt;NOTE: There were 64430 observations read from the data set IP.IP13.&lt;/P&gt;&lt;P&gt;NOTE: The data set IP.IP13TRY has 64430 observations and 177 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17.34 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.46 seconds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 18:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175250#M44977</guid>
      <dc:creator>bikash</dc:creator>
      <dc:date>2015-01-08T18:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175251#M44978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Sorry my fault. It should work just check the value of Race in the condition&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set have;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;format RaceAndEthnicity $ 20.;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If Ethnicity= "1" then RaceAndEthnicity = "Hispanic - Any Race";&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Else If Ethnicity= "2" and Race = "White" then RaceAndEthnicity = "White NH";&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Else If Ethnicity= "2" and Race = "&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12.7272720336914px;"&gt;Black or African American&lt;/SPAN&gt;" then RaceAndEthnicity = "Black NH";&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Else If Ethnicity= "2" and Race = "Asian/Native Hawaiian or Other Pacific Islander" then RaceAndEthnicity = "Asian";&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Else RaceAndEthnicity = "Others/Unknown";&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 19:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175251#M44978</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-01-08T19:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175252#M44979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked. Thanks a lot Mohamed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 19:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-variable-based-on-two-variables/m-p/175252#M44979</guid>
      <dc:creator>bikash</dc:creator>
      <dc:date>2015-01-08T19:56:52Z</dc:date>
    </item>
  </channel>
</rss>

