<?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: Combining Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-Variables/m-p/541628#M149568</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265781"&gt;@Sbon08&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone, my dataset in excel has multiple columns for race. Each column has a 1 if someone chose that race and a blank they did not (they would have a 1 in another column). I am trying to combine these all into one race variable for a logistic regression. Attached is a picture of how the raw data looks:&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-03-08 at 1.53.25 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27781i27BB9701A36E1578/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-03-08 at 1.53.25 PM.png" alt="Screen Shot 2019-03-08 at 1.53.25 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is this going to be a dependent variable or independent in the model?&lt;/P&gt;
&lt;P&gt;What would the values of your one value look like? Are all of the Q2_1 through Q2_9 to be combined or does one of those mean something such that it should not be combined such as a "refused to answer" code that really should not occur with other values?&lt;/P&gt;
&lt;P&gt;And are the variables numeric or character?&lt;/P&gt;
&lt;P&gt;By any chance did a previous step replace zero (0) values with missing? If so remove that step and something like this would work:&lt;/P&gt;
&lt;PRE&gt;data example;
   input Q2_1 - Q2_4;
   length r $ 4;
   r = cats(of Q2_:);

datalines;
1 0 0 0
1 0 1 0
0 0 0 1
; 
run;&lt;/PRE&gt;
&lt;P&gt;Using only 4 variables as I'm too lazy to make 10 when 4 demonstrates what goes on.&lt;/P&gt;
&lt;P&gt;You would need a place holder in any case.&lt;/P&gt;
&lt;P&gt;The following code shows one way to replace 0 for missing values.&lt;/P&gt;
&lt;PRE&gt;data example;
   informat Q2_1 - Q2_4 $1.;
   input Q2_1 - Q2_4 ;
   array q  Q2_1 - Q2_4;
   do i= 1 to dim(q);
      if missing(q[i]) then q[i]='0';
   end;
   length r $ 4;
   r = cats(of Q2_:);
   drop;
datalines;
1 . . .
1 . 1 .
. . . 1
; 
run;&lt;/PRE&gt;
&lt;P&gt;If you variables are numeric the only real change to the code (other than not reading data) is to use =0; instead of ='0';&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 21:51:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-03-08T21:51:10Z</dc:date>
    <item>
      <title>Combining Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-Variables/m-p/541530#M149525</link>
      <description>&lt;P&gt;Hi everyone, my dataset in excel has multiple columns for race. Each column has a 1 if someone chose that race and a blank they did not (they would have a 1 in another column). I am trying to combine these all into one race variable for a logistic regression. Attached is a picture of how the raw data looks:&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-03-08 at 1.53.25 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27781i27BB9701A36E1578/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-03-08 at 1.53.25 PM.png" alt="Screen Shot 2019-03-08 at 1.53.25 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 18:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-Variables/m-p/541530#M149525</guid>
      <dc:creator>Sbon08</dc:creator>
      <dc:date>2019-03-08T18:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-Variables/m-p/541628#M149568</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265781"&gt;@Sbon08&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone, my dataset in excel has multiple columns for race. Each column has a 1 if someone chose that race and a blank they did not (they would have a 1 in another column). I am trying to combine these all into one race variable for a logistic regression. Attached is a picture of how the raw data looks:&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-03-08 at 1.53.25 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27781i27BB9701A36E1578/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-03-08 at 1.53.25 PM.png" alt="Screen Shot 2019-03-08 at 1.53.25 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is this going to be a dependent variable or independent in the model?&lt;/P&gt;
&lt;P&gt;What would the values of your one value look like? Are all of the Q2_1 through Q2_9 to be combined or does one of those mean something such that it should not be combined such as a "refused to answer" code that really should not occur with other values?&lt;/P&gt;
&lt;P&gt;And are the variables numeric or character?&lt;/P&gt;
&lt;P&gt;By any chance did a previous step replace zero (0) values with missing? If so remove that step and something like this would work:&lt;/P&gt;
&lt;PRE&gt;data example;
   input Q2_1 - Q2_4;
   length r $ 4;
   r = cats(of Q2_:);

datalines;
1 0 0 0
1 0 1 0
0 0 0 1
; 
run;&lt;/PRE&gt;
&lt;P&gt;Using only 4 variables as I'm too lazy to make 10 when 4 demonstrates what goes on.&lt;/P&gt;
&lt;P&gt;You would need a place holder in any case.&lt;/P&gt;
&lt;P&gt;The following code shows one way to replace 0 for missing values.&lt;/P&gt;
&lt;PRE&gt;data example;
   informat Q2_1 - Q2_4 $1.;
   input Q2_1 - Q2_4 ;
   array q  Q2_1 - Q2_4;
   do i= 1 to dim(q);
      if missing(q[i]) then q[i]='0';
   end;
   length r $ 4;
   r = cats(of Q2_:);
   drop;
datalines;
1 . . .
1 . 1 .
. . . 1
; 
run;&lt;/PRE&gt;
&lt;P&gt;If you variables are numeric the only real change to the code (other than not reading data) is to use =0; instead of ='0';&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 21:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-Variables/m-p/541628#M149568</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-08T21:51:10Z</dc:date>
    </item>
  </channel>
</rss>

