<?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: Creating a Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240272#M44299</link>
    <description>&lt;P&gt;It means you have cases where aq_1=1 and aq_2=1 or any of the other aq_ variables. You can run a proc freq to check it.&lt;/P&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
set have;
if sum(of aq_1-aq_4)&amp;gt;1 then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Dec 2015 15:17:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-12-21T15:17:03Z</dc:date>
    <item>
      <title>Creating a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240260#M44296</link>
      <description>&lt;P&gt;Good day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 4 dichotomous variables, let's call them aq_1 aq_2 aq_3 and aq_4. Each variable is answered yes/no (0/1). I would like to combine these variables into one variable 'aq_combined'. The following code has not worked as the counts are not the same as when I run each variable independently. Wondering if anyone had any insight, thanks!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if aq_1 =1 then aq_combined=1;&lt;/P&gt;
&lt;P&gt;if aq_2=1 &amp;nbsp;then aq_combined=2;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if aq_3 =1 then aq_combined=3;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if aq_4 =1 then aq_combined=4;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2015 14:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240260#M44296</guid>
      <dc:creator>GregBond</dc:creator>
      <dc:date>2015-12-21T14:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240262#M44297</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code. &amp;nbsp;What you can do is use an array, as all are aq_ prefix, and take max of that array, which will be 1 if 1 is present in any, and 0 if not. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input aq_1 aq_2 aq_3 aq_4;
datalines;
1 0 1 0
0 0 0 0 
1 1 1 1
;
run;

data want;
  set have;
  array aq_{4};
  aq_combined=max(of aq_{*});
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Dec 2015 14:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240262#M44297</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-21T14:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240271#M44298</link>
      <description>&lt;P&gt;I would try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;aq_combined = aq_1 * 1000 + aq_2 * 100 + aq_3 * 10 + aq_4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This creates aq_combined as numeric.&amp;nbsp; The best answer might depend on how you are going to use aq_combined later.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2015 15:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240271#M44298</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-21T15:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240272#M44299</link>
      <description>&lt;P&gt;It means you have cases where aq_1=1 and aq_2=1 or any of the other aq_ variables. You can run a proc freq to check it.&lt;/P&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
set have;
if sum(of aq_1-aq_4)&amp;gt;1 then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Dec 2015 15:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Variable/m-p/240272#M44299</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-21T15:17:03Z</dc:date>
    </item>
  </channel>
</rss>

