<?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 Error in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/557003#M9934</link>
    <description>&lt;P&gt;I think we are close to solution!! after running this code observation length increased from 9K to 30K.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  data example;
109  set keep;
110     do RaceBlack= 0,1;
111     do RaceAsian= 0,1;
112     do RaceNativeAm= 0,1;
113     do RacNativePacefic= 0,1;
114     do RaceOther= 0,1;
115        if sum(RaceBlack,RaceAsian,RaceNativeAm,RacNativePacefic,RaceOther)&amp;gt;1 then Race=4;
116        else if RaceBlack then race=2;
117        else if RaceAsian then race=3;
118        else if  RaceNativeAm or RacNativePacefic then race=4;
119        else if RaceOther then race=1;
120        output;
121     end;
122     end;
123     end;
124     end;
125     end;
126     label
127        RaceBlack='Black'
128        RaceAsian='Asian'
129        RaceNativeAm='AI/AN'
130       RacNativePacific='NHOPI'
131        RaceOther='White or Other'
132     end;
133  run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      110:18   110:20   111:18   111:20   112:21   112:23   114:18   114:20
NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      115:14   115:24   115:34   115:64   116:15   117:15   118:16   119:15
NOTE: There were 9546 observations read from the data set WORK.KEEP.
NOTE: The data set WORK.EXAMPLE has 305472 observations and 50 variables.
NOTE: DATA statement used (Total process time):
      real time           0.65 seconds
      cpu time            0.32 seconds&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 May 2019 04:32:37 GMT</pubDate>
    <dc:creator>SChander</dc:creator>
    <dc:date>2019-05-08T04:32:37Z</dc:date>
    <item>
      <title>Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556824#M9893</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 5 Race Variable ( RaceBlack, RaceAsian, RaceNativeAM, RaceNativePacefic and RaceOther) they have dichotomous response 1.Yes , 2.No. I want to create a new Variable&amp;nbsp; "Race" and code it; Black =2, Asian = 3, Other =4 and White =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using following code it doesn't work,&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 Race;&amp;nbsp;

set ABC;

If RaceBlack = 1 then Race = 2;

If RaceBlace = 2 then delete;

If RaceAsian = 1 then Race = 3;

If RaceAsian = 2 then delete;

IF RaceNativeAM = 1 or RaceNativePacefic = 1 then Race = 4;

If RaceNativeAm = 2 or RaceNativePacefic = 2 then delete;

else Race = 1;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 15:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556824#M9893</guid>
      <dc:creator>SChander</dc:creator>
      <dc:date>2019-05-07T15:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556830#M9897</link>
      <description>&lt;P&gt;please try the below code&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 Race; 
set ABC;
If RaceBlack = 1 then Race = 2;
If RaceAsian = 1 then Race = 3;
IF RaceNativeAM = 1 or RaceNativePacefic = 1 then Race = 1;
if RaceOther=1 then Race = 4;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 16:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556830#M9897</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-07T16:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556833#M9898</link>
      <description>&lt;P&gt;Thank you for your response,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to code RaceNativeAM and RacePacefic as 4. Others and RaceOther as 1=white;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556833#M9898</guid>
      <dc:creator>SChander</dc:creator>
      <dc:date>2019-05-07T16:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556834#M9899</link>
      <description>&lt;P&gt;you can try the below code , but is it working and you are getting the expected output&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Race;
set ABC;
If RaceBlack = 1 then Race = 2;
If RaceAsian = 1 then Race = 3;
IF RaceNativeAM = 1 or RaceNativePacefic = 1 then Race = 4;
if RaceOther=1 then Race = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 16:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556834#M9899</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-07T16:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556838#M9901</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267131"&gt;@SChander&lt;/a&gt;&amp;nbsp; Please take a look at Proc format aka user defined format. All syntax and examples are available online everywhere. Define your formats once and look up as when you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF THEN statements are tedious and boring. IMHO not worth the time in your case.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556838#M9901</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-07T16:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556842#M9902</link>
      <description>&lt;P&gt;Still There is error, 8944 subjects are missing. Please find the attached file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks;&lt;/P&gt;&lt;P&gt;Subhash&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556842#M9902</guid>
      <dc:creator>SChander</dc:creator>
      <dc:date>2019-05-07T16:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556843#M9903</link>
      <description>&lt;P&gt;use &lt;CODE class=" language-sas"&gt;the below code in proc freq step&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where race ne . ; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 16:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556843#M9903</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-07T16:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556845#M9904</link>
      <description>&lt;P&gt;No luck...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It shows me missing values in each single variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556845#M9904</guid>
      <dc:creator>SChander</dc:creator>
      <dc:date>2019-05-07T16:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556847#M9905</link>
      <description>Could you please share the code you are trying</description>
      <pubDate>Tue, 07 May 2019 16:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556847#M9905</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-07T16:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556851#M9906</link>
      <description>&lt;P&gt;Please find the following code file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556851#M9906</guid>
      <dc:creator>SChander</dc:creator>
      <dc:date>2019-05-07T16:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556859#M9911</link>
      <description>&lt;P&gt;Please stop posting code and log a screenshots, post them as text using the window opened by clicking on the {i}-icon.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556859#M9911</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-05-07T16:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556861#M9912</link>
      <description>&lt;P&gt;Please do not past pictures of the LOG. It is every so much more helpful to copy the text from the LOG and paste the text into a code box opened using the forum's {I} or "running man" icons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, it is for all intents impossible to copy one or two lines of text from a picture and highlight or show the change needed. I am not going to retype a bunch of text from a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, since you have &lt;STRONG&gt;5 &lt;/STRONG&gt;variables, what do you want to happen when there are more than 1 that have a 1 value? I don't see any description of the expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267131"&gt;@SChander&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 5 Race Variable ( RaceBlack, RaceAsian, RaceNativeAM, RaceNativePacefic and RaceOther) they have dichotomous response 1.Yes , 2.No. I want to create a new Variable&amp;nbsp; "Race" and code it; Black =2, Asian = 3, Other =4 and White =1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using following code it doesn't work,&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 Race;&amp;nbsp;

set ABC;

If RaceBlack = 1 then Race = 2;

If &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;RaceBlace&lt;/FONT&gt;&lt;/STRONG&gt; = 2 then delete;

If RaceAsian = 1 then Race = 3;

If RaceAsian = 2 then delete;

IF RaceNativeAM = 1 or RaceNativePacefic = 1 then Race = 4;

If RaceNativeAm = 2 or RaceNativePacefic = 2 then delete;

else Race = 1;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First thing, it appears that you have a spelling error.&lt;/P&gt;
&lt;P&gt;Second is you are deleting entire records based on single values of each variable. Since you may have raceblack=2 and RaceAsian=1 for the same record then you delete one of your Asian expected results. And again if raceasian=2 then either the raceblack=2 or raceasian=2 would have deleted your Race=4 expected result.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556861#M9912</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-07T16:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556915#M9916</link>
      <description>&lt;P&gt;The first thing you need to learn is the meaning of "ELSE".&amp;nbsp; It does not refer to all the previous IF statements being false.&amp;nbsp; Rather, it refers to the most recent IF statement only, what to do is that one was false.&amp;nbsp; So in your program you have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
If RaceNativeAm = 2 or RaceNativePacefic = 2 then delete;

else Race = 1;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;These will set RACE to 1 for ALL observations that were not deleted by the previous statement.&amp;nbsp; So that ELSE logic needs to change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given that you haven't used ELSE until the last statement, I would recommend removing this statement entirely:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else Race = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In its place, just add this statement after the SET statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Race = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are definitely more sophisticated ways to handle this, but you have to be more familiar with ELSE first.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If RaceBlack = 1 then Race = 2;

Else If RaceBlace = 2 then delete;

Else If RaceAsian = 1 then Race = 3;

Else If RaceAsian = 2 then delete;

Else IF RaceNativeAM = 1 or RaceNativePacefic = 1 then Race = 4;

Else If RaceNativeAm = 2 or RaceNativePacefic = 2 then delete;

else Race = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 18:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556915#M9916</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-07T18:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556948#M9925</link>
      <description>&lt;P&gt;Personally I would recode 1=Yes , 2=No to 1=Yes and 0=No as the first step. Too lazy to type out your long variable names but this shows some of why I would use the more traditional 1/0 coding.&lt;/P&gt;
&lt;PRE&gt;data example;
   do a= 0,1;
   do b= 0,1;
   do c= 0,1;
   do d= 0,1;
   do e= 0,1;
      if sum(a,b,c,d,e)&amp;gt;1 then Race=4;
      else if a then race=2;
      else if b then race=3;
      else if c or d then race=4;
      else if e then race=1;
      output;
   end;
   end;
   end;
   end;
   end;
   label
      a='Black'
      b='Asian'
      c='AI/AN'
      d='NHOPI'
      e='White or Other'
   end;
run;

proc freq data=example;
 table a*b*c*d*e*race /list nocum nopercent missing;
run;&lt;/PRE&gt;
&lt;P&gt;NOTE: You have not provided any clue what you want for respondents that answer NO to all of your 5 questions. From experience you might have Hispanic respondents do that with moderate frequency as so many people refer to "Hispanic" as a race and depending on your actual data collection instrument that may happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note the way I provided example data for all of the possible Yes/No responses for 5 variables, as code others could use.&lt;/P&gt;
&lt;P&gt;And the PROC Freq shows results in a way that is easy to see if the coding is doing what is intended.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 21:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/556948#M9925</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-07T21:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Race Error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/557003#M9934</link>
      <description>&lt;P&gt;I think we are close to solution!! after running this code observation length increased from 9K to 30K.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  data example;
109  set keep;
110     do RaceBlack= 0,1;
111     do RaceAsian= 0,1;
112     do RaceNativeAm= 0,1;
113     do RacNativePacefic= 0,1;
114     do RaceOther= 0,1;
115        if sum(RaceBlack,RaceAsian,RaceNativeAm,RacNativePacefic,RaceOther)&amp;gt;1 then Race=4;
116        else if RaceBlack then race=2;
117        else if RaceAsian then race=3;
118        else if  RaceNativeAm or RacNativePacefic then race=4;
119        else if RaceOther then race=1;
120        output;
121     end;
122     end;
123     end;
124     end;
125     end;
126     label
127        RaceBlack='Black'
128        RaceAsian='Asian'
129        RaceNativeAm='AI/AN'
130       RacNativePacific='NHOPI'
131        RaceOther='White or Other'
132     end;
133  run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      110:18   110:20   111:18   111:20   112:21   112:23   114:18   114:20
NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      115:14   115:24   115:34   115:64   116:15   117:15   118:16   119:15
NOTE: There were 9546 observations read from the data set WORK.KEEP.
NOTE: The data set WORK.EXAMPLE has 305472 observations and 50 variables.
NOTE: DATA statement used (Total process time):
      real time           0.65 seconds
      cpu time            0.32 seconds&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 04:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coding-Race-Error/m-p/557003#M9934</guid>
      <dc:creator>SChander</dc:creator>
      <dc:date>2019-05-08T04:32:37Z</dc:date>
    </item>
  </channel>
</rss>

