<?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: Coding Race Variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206779#M51380</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yet another way:&lt;/P&gt;&lt;P&gt;I read in Yes/no variables as 1 and 0 with custom informats. The Race0 = (Sum(raceA,&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;raceB,raceP,raceI, raceW)&amp;gt;1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;(I also tend to name such thins Race1 through 5 so Race1-Race5 makes better lists). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jul 2015 20:10:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-07-20T20:10:16Z</dc:date>
    <item>
      <title>Coding Race Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206775#M51376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For each obs, I have 5 variables related to race (raceA, raceB, raceP, raceI and raceW).&amp;nbsp; If 4 of the variables = 'N' and one of them = 'Y' then coding the race is easy.&amp;nbsp; subgrp_race will be defined by the field that has the 'Y.'&amp;nbsp; However, if two or more fields = 'Y' then I will define a new variable (RaceO) to denote that two or more races were chosen by the student.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a proc freq below that shows the table raceA*raceB*raceP*raceI*raceW/ list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know I can write a buttload of if then statements but there has to be something more elegant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Freq: LIST Frequencies"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD colspan="1"&gt;raceA&lt;/TD&gt;&lt;TD colspan="1"&gt;raceB&lt;/TD&gt;&lt;TD colspan="1"&gt;raceP&lt;/TD&gt;&lt;TD colspan="1"&gt;raceI&lt;/TD&gt;&lt;TD colspan="1"&gt;raceW&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;3992&lt;/TD&gt;&lt;TD class="r data"&gt;86.31&lt;/TD&gt;&lt;TD class="r data"&gt;3992&lt;/TD&gt;&lt;TD class="r data"&gt;86.31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TD class="r data"&gt;4&lt;/TD&gt;&lt;TD class="r data"&gt;0.09&lt;/TD&gt;&lt;TD class="r data"&gt;3996&lt;/TD&gt;&lt;TD class="r data"&gt;86.40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;21&lt;/TD&gt;&lt;TD class="r data"&gt;0.45&lt;/TD&gt;&lt;TD class="r data"&gt;4017&lt;/TD&gt;&lt;TD class="r data"&gt;86.85&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TD class="r data"&gt;1&lt;/TD&gt;&lt;TD class="r data"&gt;0.02&lt;/TD&gt;&lt;TD class="r data"&gt;4018&lt;/TD&gt;&lt;TD class="r data"&gt;86.88&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;4&lt;/TD&gt;&lt;TD class="r data"&gt;0.09&lt;/TD&gt;&lt;TD class="r data"&gt;4022&lt;/TD&gt;&lt;TD class="r data"&gt;86.96&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TD class="r data"&gt;385&lt;/TD&gt;&lt;TD class="r data"&gt;8.32&lt;/TD&gt;&lt;TD class="r data"&gt;4407&lt;/TD&gt;&lt;TD class="r data"&gt;95.29&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;157&lt;/TD&gt;&lt;TD class="r data"&gt;3.39&lt;/TD&gt;&lt;TD class="r data"&gt;4564&lt;/TD&gt;&lt;TD class="r data"&gt;98.68&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;3&lt;/TD&gt;&lt;TD class="r data"&gt;0.06&lt;/TD&gt;&lt;TD class="r data"&gt;4567&lt;/TD&gt;&lt;TD class="r data"&gt;98.75&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TD class="r data"&gt;36&lt;/TD&gt;&lt;TD class="r data"&gt;0.78&lt;/TD&gt;&lt;TD class="r data"&gt;4603&lt;/TD&gt;&lt;TD class="r data"&gt;99.52&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;16&lt;/TD&gt;&lt;TD class="r data"&gt;0.35&lt;/TD&gt;&lt;TD class="r data"&gt;4619&lt;/TD&gt;&lt;TD class="r data"&gt;99.87&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TD class="r data"&gt;3&lt;/TD&gt;&lt;TD class="r data"&gt;0.06&lt;/TD&gt;&lt;TD class="r data"&gt;4622&lt;/TD&gt;&lt;TD class="r data"&gt;99.94&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TD class="r data"&gt;1&lt;/TD&gt;&lt;TD class="r data"&gt;0.02&lt;/TD&gt;&lt;TD class="r data"&gt;4623&lt;/TD&gt;&lt;TD class="r data"&gt;99.96&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;N&lt;/TH&gt;&lt;TH class="l rowheader" scope="row"&gt;Y&lt;/TH&gt;&lt;TD class="r data"&gt;2&lt;/TD&gt;&lt;TD class="r data"&gt;0.04&lt;/TD&gt;&lt;TD class="r data"&gt;4625&lt;/TD&gt;&lt;TD class="r data"&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 18:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206775#M51376</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2015-07-20T18:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206776#M51377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the code below, I believe it will give you what you want if I'm understanding your description correctly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input raceA$ raceB$ raceP$ raceI$ raceW$;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;N N N N Y&lt;/P&gt;&lt;P&gt;N N N Y N&lt;/P&gt;&lt;P&gt;N N N Y Y&lt;/P&gt;&lt;P&gt;N N Y N N&lt;/P&gt;&lt;P&gt;N N Y N Y&lt;/P&gt;&lt;P&gt;N Y N N N&lt;/P&gt;&lt;P&gt;N Y N N Y&lt;/P&gt;&lt;P&gt;N Y N Y Y&lt;/P&gt;&lt;P&gt;Y N N N N&lt;/P&gt;&lt;P&gt;Y N N N Y&lt;/P&gt;&lt;P&gt;Y N Y N N&lt;/P&gt;&lt;P&gt;Y Y N N N&lt;/P&gt;&lt;P&gt;Y Y N N Y&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data=have noprint&lt;/P&gt;&lt;P&gt;out=have_contents (keep=NAME);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro race;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;set have_contents end=lastobs;&lt;/P&gt;&lt;P&gt;call symputx(cats('race',_n_),NAME);&lt;/P&gt;&lt;P&gt;if lastobs then call symputx('n',_n_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;combine=catx(',',raceA,raceB,raceP,raceI,raceW);&lt;/P&gt;&lt;P&gt;If countc(combine,"Y")&amp;gt;1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raceO="Y";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subgrp_race="raceO"; end;&lt;/P&gt;&lt;P&gt;Else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If &amp;amp;&amp;amp;race&amp;amp;i="Y" then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raceO="N";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subgrp_race="&amp;amp;&amp;amp;race&amp;amp;i"; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end; end;&lt;/P&gt;&lt;P&gt;drop combine;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%race&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 18:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206776#M51377</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-07-20T18:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206777#M51378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 18:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206777#M51378</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2015-07-20T18:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206778#M51379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can simply:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;o=count(cats(of race:),'Y')&amp;gt;1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;O =1 when you have more than 'Y' selected, otherwise O=0. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 18:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206778#M51379</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-07-20T18:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206779#M51380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yet another way:&lt;/P&gt;&lt;P&gt;I read in Yes/no variables as 1 and 0 with custom informats. The Race0 = (Sum(raceA,&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;raceB,raceP,raceI, raceW)&amp;gt;1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: SAS Monospace;"&gt;(I also tend to name such thins Race1 through 5 so Race1-Race5 makes better lists). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 20:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Coding-Race-Variables/m-p/206779#M51380</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-07-20T20:10:16Z</dc:date>
    </item>
  </channel>
</rss>

