<?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 Help transposing data. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763867#M241923</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset with a CompanyCode variable, and a datetime variable DischargeFullDate for dates from January-July as shown for example in the photos below. I'm trying to find the % of people in each CompanyCode for every month so for example: The % of people in the month of January for CompanyCode 900, 901,......,etc. and transpose the data to look like&lt;/P&gt;&lt;P&gt;&lt;U&gt;Company Code| Jan-21 | Feb-21 | Mar-21| etc.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;901&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;|&amp;nbsp; &amp;nbsp; &amp;nbsp;%&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp; %&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;%&amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;902&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Company Codes example" style="width: 66px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62987i843463B8C029A0A2/image-dimensions/66x204?v=v2" width="66" height="204" role="button" title="Company Code.PNG" alt="Company Codes example" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Company Codes example&lt;/span&gt;&lt;/span&gt;&lt;U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Datetime example" style="width: 161px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62986i8E584BEF7D861059/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Datetime example" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Datetime example&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62990iB9DF9E02D72D1F03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Aug 2021 14:31:27 GMT</pubDate>
    <dc:creator>zouinenoah</dc:creator>
    <dc:date>2021-08-25T14:31:27Z</dc:date>
    <item>
      <title>Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763867#M241923</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset with a CompanyCode variable, and a datetime variable DischargeFullDate for dates from January-July as shown for example in the photos below. I'm trying to find the % of people in each CompanyCode for every month so for example: The % of people in the month of January for CompanyCode 900, 901,......,etc. and transpose the data to look like&lt;/P&gt;&lt;P&gt;&lt;U&gt;Company Code| Jan-21 | Feb-21 | Mar-21| etc.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;901&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;|&amp;nbsp; &amp;nbsp; &amp;nbsp;%&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp; %&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;%&amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;902&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Company Codes example" style="width: 66px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62987i843463B8C029A0A2/image-dimensions/66x204?v=v2" width="66" height="204" role="button" title="Company Code.PNG" alt="Company Codes example" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Company Codes example&lt;/span&gt;&lt;/span&gt;&lt;U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Datetime example" style="width: 161px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62986i8E584BEF7D861059/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Datetime example" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Datetime example&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62990iB9DF9E02D72D1F03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 14:31:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763867#M241923</guid>
      <dc:creator>zouinenoah</dc:creator>
      <dc:date>2021-08-25T14:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763870#M241925</link>
      <description>&lt;P&gt;So you want a report of how many people per month?&lt;/P&gt;
&lt;P&gt;What does the raw data look like?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 14:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763870#M241925</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-25T14:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763873#M241926</link>
      <description>&lt;P&gt;Are you sure that you want a data set? A report that shows such things is likely to be much easier. Any data set in that sort of "wide" format gets to be awkward to work with for many analysis tasks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pseudo code for a report of what I think you are asking:&lt;/P&gt;
&lt;PRE&gt;Proc tabulate data=have;
   class companycode dischargefulldate;
   format dischargefulldate dtmonyy7.;
   table companycode,
         dischargefulldate*rowpctn
  ;
run;&lt;/PRE&gt;
&lt;P&gt;Groups created by formats will be honored in the reporting procedures like this and most analysis procedures.&lt;/P&gt;
&lt;P&gt;If this is close then additional options can modify appearance a bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Four-digit years really are a good idea.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 14:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763873#M241926</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-25T14:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763876#M241927</link>
      <description>&lt;P&gt;The table output that this gives, works perfect still. Is there a way to still include the company codes that have no values. Such as like CompanyCode 901 has no entries for all 7 months, is there a way to include it in the table even having no values?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 15:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763876#M241927</guid>
      <dc:creator>zouinenoah</dc:creator>
      <dc:date>2021-08-25T15:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763882#M241929</link>
      <description>&lt;P&gt;Yes, but you need to use a PRELOADFMT or add it as a record with all missing values to your main data set. Basically if the data does not exist, you do need to find some way to tell SAS that it does exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A few ways to do this are outlined here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.lexjansen.com/nesug/nesug11/cc/cc29.pdf" target="_blank"&gt;https://www.lexjansen.com/nesug/nesug11/cc/cc29.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 15:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763882#M241929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-25T15:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763886#M241931</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/392386"&gt;@zouinenoah&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The table output that this gives, works perfect still. Is there a way to still include the company codes that have no values. Such as like CompanyCode 901 has no entries for all 7 months, is there a way to include it in the table even having no values?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. The easiest, IF you know all the codes that you need in the report is a custom format and some options in the Proc Tabulate code.&lt;/P&gt;
&lt;P&gt;The format would look something like:&lt;/P&gt;
&lt;PRE&gt;Proc format;
value $companycode
'901'= '901'
'902'= '902'
'903'= '903'
;&lt;/PRE&gt;
&lt;P&gt;If you have a data set with the codes that can be used to create a format, which may be the better course in the long run but the example as above , with all the codes you want to appear, would be the basis. I am assuming, since no actual data is available that the codes are character. If the values are actually numeric modify the above code by removing the $ on the value statement and the quotes around the values on the left of the equal sign: i.e. 901 = '901'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in the Proc Tabulate code:&lt;/P&gt;
&lt;PRE&gt;Proc tabulate data=have;
   class companycode /preloadfmt order=data;&lt;BR /&gt;   format companycode $companycode. ;&lt;BR /&gt;   class dischargefulldate;
   format dischargefulldate dtmonyy7.;
   table companycode,
         dischargefulldate*rowpctn
  ;
run;&lt;/PRE&gt;
&lt;P&gt;The option on the class statement PRELOADFMT says to use all the values of the assigned format. Caution: This option does not work with things like dates and times or continuous numeric formats, only&amp;nbsp; something with a fairly explicit list of values. The PRELOADFMT requires either the option data=order or the table option PRINTMISS. Look in the Tabulate documentation for more details.&lt;/P&gt;
&lt;P&gt;Note that you can have multiple Class statements to provide different options for different variables. The Class variables provide row and column headers.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 15:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763886#M241931</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-25T15:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help transposing data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763892#M241933</link>
      <description>&lt;P&gt;Thank you! I just had to add the /printmiss after the DischargeFullDate*rowpctn to display them in the table.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 16:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-transposing-data/m-p/763892#M241933</guid>
      <dc:creator>zouinenoah</dc:creator>
      <dc:date>2021-08-25T16:31:00Z</dc:date>
    </item>
  </channel>
</rss>

