<?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: Sex distribution vertical columns in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784107#M32063</link>
    <description>&lt;P&gt;Formats are an extremely powerful tool in SAS. You can display or perform different analysis for the same values just by changing the format.&lt;/P&gt;
&lt;P&gt;For example I have formats for persons age that do 3-year , 5-year,10-year intervals plus specific age ranges such as 0-5, 6-13,14-18, or 18-24,25-44,45 and older, or over/under some specific age limit, 18, 21 for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The groups created by the formats are honored by analysis, reporting and graphing procedures. So just changing the format name in procedure like SGPLOT I change from showing the 5-year groups to the over/under 18.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if the boss wants more text instead of "Male" to "Adult Male" or "M" or "Male with Diabetes", create a new format with the different label on an axis or table header.&lt;/P&gt;</description>
    <pubDate>Sat, 04 Dec 2021 18:53:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-12-04T18:53:25Z</dc:date>
    <item>
      <title>Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784068#M32052</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a large dataset with the variable p_sex.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a subset of data including only the sex variable (p_sex).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data sex; set output_data;
where redcap_repeat_instrument = "demographics";
keep p_sex;
run;

proc gchart data=sex;
vbar p_sex;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expected 2 columns (one for female and one for male),&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I got a chart with a lot of empty columns in between&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JT9_0-1638616206193.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66403i2309C0BB318834FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JT9_0-1638616206193.png" alt="JT9_0-1638616206193.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset called sex is as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JT9_1-1638616281699.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66404iCEE69AB429077634/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JT9_1-1638616281699.png" alt="JT9_1-1638616281699.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any statement I am missing to make sure only to get two columns representing 1 and 2, respectively&amp;nbsp;&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 11:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784068#M32052</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-04T11:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784069#M32053</link>
      <description>&lt;P&gt;Treat gender as a category variable (instead of what you are doing which seems to treat gender as continuous).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PROC SGPLOT with the VBAR statement. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.class;
    vbar sex;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Dec 2021 12:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784069#M32053</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-04T12:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784071#M32054</link>
      <description>Thank you so much.&lt;BR /&gt;I tried to apply your code without changing anything.&lt;BR /&gt;&lt;BR /&gt;proc sgplot data=output_data;&lt;BR /&gt;vbar p_sex;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;This helped. Got only 2 bars. THANK YOU&lt;BR /&gt;&lt;BR /&gt;Can I label in the code or rename the row name before running the code:&lt;BR /&gt;- 1 for male&lt;BR /&gt;- 2 for female ?&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Dec 2021 12:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784071#M32054</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-04T12:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784074#M32055</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.class;
 set sashelp.class;
 p_sex = (sex='F'); /*  Boolean expression       */
 p_sex = p_sex + 1; /* 1 for male ; 2 for female */
run;

/*
proc gchart data=work.class;
 vbar p_sex;
run;
QUIT;
*/

proc sgplot data=work.class;
   title "abc xyz";
   vbar p_sex;
run;
title;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 12:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784074#M32055</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-04T12:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784077#M32056</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I copy and apply this code directly to SAS, I get this output:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JT9_0-1638623394262.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66405i3C999464AD7F69D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JT9_0-1638623394262.png" alt="JT9_0-1638623394262.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like 1 and 2 to be replaced - in stead female and male&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that not possible&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 13:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784077#M32056</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-04T13:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784078#M32057</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.class;
 LENGTH sexFM $ 6;
 set sashelp.class;
 p_sex = (sex='F'); /*  Boolean expression       */
 p_sex = p_sex + 1; /* 1 for male ; 2 for female */
 if      p_sex = 1 then sexFM ='Male';
 else if p_sex = 2 then sexFM ='Female';
 else;
run;

proc sgplot data=work.class;
   title "abc xyz";
   vbar sexFM;
   xaxis label='sexFM : Male and Female variable';
run;
title;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 13:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784078#M32057</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-04T13:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784080#M32058</link>
      <description>&lt;P&gt;Perfect , thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see the first part of the code is making a new column called sexFm with the replaced numbers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried deleting row 4-5 and tried running the code. There were no differences, so I deleted those and still got it presentated as I wished.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem solved. Thanks a lot !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 13:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784080#M32058</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-04T13:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784081#M32059</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.class;
 LENGTH sexFM $ 6;
 set sashelp.class;
 p_sex = (sex='F'); /*  Boolean expression       */
 p_sex = p_sex + 1; /* 1 for male ; 2 for female */
 if      p_sex = 1 then sexFM ='Male';
 else if p_sex = 2 then sexFM ='Female';
 else;
run;

proc sgplot data=work.class;
   title "abc xyz";
   vbar sexFM;
   xaxis label='sexFM : Male and Female variable';
run;
title;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Koen&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have a different solution for the original data set from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404450"&gt;@rookie21&lt;/a&gt;&amp;nbsp;, which I think is a lot simpler, and a lot less typing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value sexf 1='Male' 2='Female';
run;
proc sgplot data=sex;
    vbar p_sex;
    xaxis valuesformat=sexf.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 14:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784081#M32059</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-04T14:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784084#M32060</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404450"&gt;@rookie21&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just make sure that 1 and 2 are correctly mapped to Male and Female respectively.&lt;BR /&gt;But maybe you want it (or it is) 'the other way around'.&lt;/P&gt;
&lt;P&gt;I do not know whether your 1 equals 'Male' and your 2 equals 'Female' (maybe it's the other way around).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 14:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784084#M32060</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-04T14:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784087#M32061</link>
      <description>Yes, I will double check, thx</description>
      <pubDate>Sat, 04 Dec 2021 16:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784087#M32061</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-04T16:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784088#M32062</link>
      <description>Thank you, the shorter, the better &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sat, 04 Dec 2021 16:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784088#M32062</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-04T16:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sex distribution vertical columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784107#M32063</link>
      <description>&lt;P&gt;Formats are an extremely powerful tool in SAS. You can display or perform different analysis for the same values just by changing the format.&lt;/P&gt;
&lt;P&gt;For example I have formats for persons age that do 3-year , 5-year,10-year intervals plus specific age ranges such as 0-5, 6-13,14-18, or 18-24,25-44,45 and older, or over/under some specific age limit, 18, 21 for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The groups created by the formats are honored by analysis, reporting and graphing procedures. So just changing the format name in procedure like SGPLOT I change from showing the 5-year groups to the over/under 18.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if the boss wants more text instead of "Male" to "Adult Male" or "M" or "Male with Diabetes", create a new format with the different label on an axis or table header.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 18:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sex-distribution-vertical-columns/m-p/784107#M32063</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-04T18:53:25Z</dc:date>
    </item>
  </channel>
</rss>

