<?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 single categorical variable from other categorical variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728576#M226695</link>
    <description>&lt;P&gt;Yes, I noticed that were not mutually exclusive after running the code with the array statement. I was over writing the conditions. Thank you for this observation&lt;/P&gt;</description>
    <pubDate>Tue, 23 Mar 2021 21:28:38 GMT</pubDate>
    <dc:creator>UcheOkoro</dc:creator>
    <dc:date>2021-03-23T21:28:38Z</dc:date>
    <item>
      <title>Creating a single categorical variable from other categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728569#M226691</link>
      <description>&lt;P&gt;Please, I need help creating a single categorical variables from several categorical variables. The categorical variables from which I would like to create a single variable are Agitation(1, 0), Akathisia(1, 0),&amp;nbsp; Anxiety_Depression(1, 0),&amp;nbsp; Arrhythmia(1, 0), Cough(1, 0),&amp;nbsp; Dizziness(1, 0), Home_medication(1, 0), Other(1, 0),&amp;nbsp; Pain(1, 0), Psychosis(1, 0),&amp;nbsp; Secretion(1, 0)&amp;nbsp; and High_Bld_Pressure(1, 0). They are mutually exclusive. I would like to create a variable called indication that will have the disease name as observation eg(Agitiation, Cough, Dizziness etc). The code I have below seems to exclude some&amp;nbsp; observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data long232c;
set long232b;
 if Agitation=1 then Indication='Agitation';
if Akathisia=1 then Indication='Akathisia';
if Anxiety_Depression=1 then Indication='Anxiety_Dep';
if Arrhythmia=1 then Indication='Arrhythmia';
if Cough=1 then Indication='Cough';
if Dizziness=1 then Indication='Dizziness';
if Fever=1 then Indication='Fever';
if High_Bld_Pressure=1 then Indication='HBP';
if Home_medication ne . and Home_medication=1 then Indication='Home_med';
if Nausea_Vomiting=1 then Indication='Nausea_Vom';
if Other= 1 then Indication='Other';
if Pain=1 then Indication='Pain';
if Psychosis=1 then Indication='Psychosis';
if Secretion=1 then Indication='Secretion';
if Seizure=1 then Indication='Seizure';
if Sleep_disturbance=1 then Indication='Sleep_dist';
if Shortness_of_breath=1 then Indication='SOB';
if Spasm=1 then Indication='Spasm';
if Swelling=1 then Indication='Swelling';
if Withdrawal=1 then Indication='Withdrawal';run;

proc freq data=long232c;
table Indication Agitation Akathisia Anxiety_Depression Arrhythmia Cough Dizziness Home_medication Other Pain Psychosis Secretion High_Bld_Pressure;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_0-1616533881609.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56339i37F20054CFB7F65C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_0-1616533881609.png" alt="UcheOkoro_0-1616533881609.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_1-1616533924859.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56340i710B4EE8A9B4224C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_1-1616533924859.png" alt="UcheOkoro_1-1616533924859.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 21:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728569#M226691</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2021-03-23T21:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a single categorical variable from other categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728572#M226693</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data long232c;
set long232b;

array _issues(*) agitation --withdrawal;

length indications $512.;
call missing(indications);

do i=1 to dim(_issues);
if _issues(i) = 1 then do;
indications = catx(",", trim(indications), vname(_issues(i)));
end;&lt;BR /&gt;end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Key concepts here are arrays, the usage of the VNAME function to get the disease from the variable name and CATX() to append the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested but should get you started.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319831"&gt;@UcheOkoro&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Please, I need help creating a single categorical variables from several categorical variables. The categorical variables from which I would like to create a single variable are Agitation(1, 0), Akathisia(1, 0),&amp;nbsp; Anxiety_Depression(1, 0),&amp;nbsp; Arrhythmia(1, 0), Cough(1, 0),&amp;nbsp; Dizziness(1, 0), Home_medication(1, 0), Other(1, 0),&amp;nbsp; Pain(1, 0), Psychosis(1, 0),&amp;nbsp; Secretion(1, 0)&amp;nbsp; and High_Bld_Pressure(1, 0). They are mutually exclusive. I would like to create a variable called indication that will have the disease name as observation eg(Agitiation, Cough, Dizziness etc). The code I have below seems to exclude some&amp;nbsp; observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data long232c;
set long232b;
 if Agitation=1 then Indication='Agitation';
if Akathisia=1 then Indication='Akathisia';
if Anxiety_Depression=1 then Indication='Anxiety_Dep';
if Arrhythmia=1 then Indication='Arrhythmia';
if Cough=1 then Indication='Cough';
if Dizziness=1 then Indication='Dizziness';
if Fever=1 then Indication='Fever';
if High_Bld_Pressure=1 then Indication='HBP';
if Home_medication ne . and Home_medication=1 then Indication='Home_med';
if Nausea_Vomiting=1 then Indication='Nausea_Vom';
if Other= 1 then Indication='Other';
if Pain=1 then Indication='Pain';
if Psychosis=1 then Indication='Psychosis';
if Secretion=1 then Indication='Secretion';
if Seizure=1 then Indication='Seizure';
if Sleep_disturbance=1 then Indication='Sleep_dist';
if Shortness_of_breath=1 then Indication='SOB';
if Spasm=1 then Indication='Spasm';
if Swelling=1 then Indication='Swelling';
if Withdrawal=1 then Indication='Withdrawal';run;

proc freq data=long232c;
table Indication Agitation Akathisia Anxiety_Depression Arrhythmia Cough Dizziness Home_medication Other Pain Psychosis Secretion High_Bld_Pressure;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_0-1616533881609.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56339i37F20054CFB7F65C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_0-1616533881609.png" alt="UcheOkoro_0-1616533881609.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_1-1616533924859.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56340i710B4EE8A9B4224C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_1-1616533924859.png" alt="UcheOkoro_1-1616533924859.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 21:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728572#M226693</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-23T21:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a single categorical variable from other categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728574#M226694</link>
      <description>I suspect you're overwriting your conditions, ie I don't think your  categories are mutually exclusive. You test for COUGH but if you have COUGH AND Swelling for example, it'll only show swelling and the COUGH portion is erased because of how you're coding the variables. &lt;BR /&gt;You can check this with a multiway proc freq check. &lt;BR /&gt;&lt;BR /&gt;proc freq data=have;&lt;BR /&gt;table home_medication*cough*pain*.........;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 23 Mar 2021 21:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728574#M226694</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-23T21:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a single categorical variable from other categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728576#M226695</link>
      <description>&lt;P&gt;Yes, I noticed that were not mutually exclusive after running the code with the array statement. I was over writing the conditions. Thank you for this observation&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 21:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-single-categorical-variable-from-other-categorical/m-p/728576#M226695</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2021-03-23T21:28:38Z</dc:date>
    </item>
  </channel>
</rss>

