<?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: Assistance in reformatting multicategorical variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859076#M339434</link>
    <description>&lt;P&gt;Hi there I did not mean to make you guess. I assumed the description above is sufficient to know what I wanted. But here is what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the genderid there are multiple subcategories&lt;/P&gt;&lt;P&gt;Genderid =&amp;nbsp;&lt;/P&gt;&lt;P&gt;Female&lt;/P&gt;&lt;P&gt;Male&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unknown/Missing&lt;/P&gt;&lt;P&gt;Transgender Male&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What want to do is breakdown each subcategories to have a binary result:&lt;/P&gt;&lt;P&gt;Female Y/N&lt;/P&gt;&lt;P&gt;Male Y/N&lt;/P&gt;&lt;P&gt;Unknown Y/N&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need more clarifications.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 22:34:33 GMT</pubDate>
    <dc:creator>aigiss</dc:creator>
    <dc:date>2023-02-15T22:34:33Z</dc:date>
    <item>
      <title>Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859049#M339420</link>
      <description>&lt;P&gt;Hello everyone. I have a dataset called combined_dataset. I have a variable called "genderid" with multiple subcategorical variables, see below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aigiss_0-1676493123988.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80444i01D61F3EE048AF32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aigiss_0-1676493123988.png" alt="aigiss_0-1676493123988.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to conduct a 2x2 table with each of these subcategorical variables with my disease outcome of interest. However, I need to make each categories into a binary variable. I tried doing female by doing this code:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;proc format;
  value $female
    "female" = "yes"
    other = "no";
run;
data combined_dataset;
  set k.combined_dataset;
  if genderid = "Female" then Female2= "Yes";
  else Female2= "No";
run;&lt;/LI-CODE&gt;&lt;P&gt;However I looked over the frequency table for that specific variable, I get this result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aigiss_1-1676493267420.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80445i7EF34603CEDC4DA1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aigiss_1-1676493267420.png" alt="aigiss_1-1676493267420.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong? I appreciate all the help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 20:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859049#M339420</guid>
      <dc:creator>aigiss</dc:creator>
      <dc:date>2023-02-15T20:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859058#M339422</link>
      <description>&lt;P&gt;If you want to use a format make sure the actual values of the variable are used. Your Proc freq output shows "Female" but your format wants to use "female". You also do not use the format $female anywhere so I am not sure why you include that.&lt;/P&gt;
&lt;P&gt;I would expect this to yield what I think you want.&lt;/P&gt;
&lt;PRE&gt;proc format;
  value $female
    "Female" = "Yes"
    other = "No";
run;

proc freq data=k.combined_dataset;
   tables genderid;
   format genderid $female. ;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the LOG for the Proc Freq that generated the "incorrect" output. If needed re-run the code. Then go to the log, copy from the log the code and all the notes or messages and then on the forum open a text box with the &amp;lt;/&amp;gt; icon and paste the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may have to re-run the data step showing us the log there as well. I might expect that shown incorrect output if a prior data step had run as and not actually replaced with code that used the "else Female2="No"; "&lt;/P&gt;
&lt;PRE&gt;data combined_dataset;
  set k.combined_dataset;
  if genderid = "Female" then Female2= "Yes";
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2023 20:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859058#M339422</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-15T20:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859062#M339423</link>
      <description>&lt;P&gt;This is the result of the last code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aigiss_0-1676495522736.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80447iC2D84D45BD513E1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aigiss_0-1676495522736.png" alt="aigiss_0-1676495522736.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The log shows no issue of the proposed code. However, the issue is that I cannot conduct other multivariables I need to reformat. This is not what I am looking for.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 21:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859062#M339423</guid>
      <dc:creator>aigiss</dc:creator>
      <dc:date>2023-02-15T21:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859066#M339426</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405522"&gt;@aigiss&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is the result of the last code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aigiss_0-1676495522736.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80447iC2D84D45BD513E1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aigiss_0-1676495522736.png" alt="aigiss_0-1676495522736.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The log shows no issue of the proposed code. However, the issue is that I cannot conduct other multivariables I need to reformat. This is not what I am looking for.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then show us what your are looking for. Please do not make us guess. Your only example shows one format and one variable with two values. So we have no idea what you may want.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 21:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859066#M339426</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-15T21:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859071#M339431</link>
      <description>I would instead recommend dummy coding your categorical variable. &lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2020/08/31/best-generate-dummy-variables-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2020/08/31/best-generate-dummy-variables-sas.html&lt;/A&gt;</description>
      <pubDate>Wed, 15 Feb 2023 22:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859071#M339431</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-15T22:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859076#M339434</link>
      <description>&lt;P&gt;Hi there I did not mean to make you guess. I assumed the description above is sufficient to know what I wanted. But here is what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the genderid there are multiple subcategories&lt;/P&gt;&lt;P&gt;Genderid =&amp;nbsp;&lt;/P&gt;&lt;P&gt;Female&lt;/P&gt;&lt;P&gt;Male&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unknown/Missing&lt;/P&gt;&lt;P&gt;Transgender Male&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What want to do is breakdown each subcategories to have a binary result:&lt;/P&gt;&lt;P&gt;Female Y/N&lt;/P&gt;&lt;P&gt;Male Y/N&lt;/P&gt;&lt;P&gt;Unknown Y/N&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need more clarifications.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 22:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859076#M339434</guid>
      <dc:creator>aigiss</dc:creator>
      <dc:date>2023-02-15T22:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859078#M339436</link>
      <description>This generates a 2x1 table in PROC FREQ not a 2x2 table. If you want a 2x2 table some other variable must be identified.</description>
      <pubDate>Wed, 15 Feb 2023 22:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859078#M339436</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-15T22:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859079#M339437</link>
      <description>&lt;P&gt;Correct. And to do so I would like to create a new variable column that has females with Y/N (observations are string) under the genderid variable.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 22:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859079#M339437</guid>
      <dc:creator>aigiss</dc:creator>
      <dc:date>2023-02-15T22:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859082#M339438</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option validvarname=v7;
proc format;
value yesno 
1='Yes' 0='No';
run;

proc glmselect data=sashelp.class NOPRINT outdesign(addinputvars)=Want;
   class      sex;   /* list the categorical variables here */
   model weight = sex /  noint selection=none;
run;

proc freq data=want;
table sex_f sex_m;
format sex_: yesno.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can run this to see how the dummy variables in the example I linked to previously make this trivial to do.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 23:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859082#M339438</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-15T23:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance in reformatting multicategorical variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859084#M339439</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405522"&gt;@aigiss&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there I did not mean to make you guess. I assumed the description above is sufficient to know what I wanted. But here is what I want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the genderid there are multiple subcategories&lt;/P&gt;
&lt;P&gt;Genderid =&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Female&lt;/P&gt;
&lt;P&gt;Male&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unknown/Missing&lt;/P&gt;
&lt;P&gt;Transgender Male&amp;nbsp;&lt;/P&gt;
&lt;P&gt;etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What want to do is breakdown each subcategories to have a binary result:&lt;/P&gt;
&lt;P&gt;Female Y/N&lt;/P&gt;
&lt;P&gt;Male Y/N&lt;/P&gt;
&lt;P&gt;Unknown Y/N&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you need more clarifications.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Mud. Clear as.&lt;/P&gt;
&lt;P&gt;Provide some data with values of the genderid as data step code or at least plain text pasted into a text box, not a picture (cannot code against pictures) and then show a manually created report /count of what you are expecting from that example data. Make sure the counts are different numbers so we can trace some logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 23:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assistance-in-reformatting-multicategorical-variable/m-p/859084#M339439</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-15T23:12:21Z</dc:date>
    </item>
  </channel>
</rss>

