<?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: Create a personalized table in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119081#M32829</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or using Reeza's TEST data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc tabulate data=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class age name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table age='',name='' * n=''&lt;/P&gt;&lt;P&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; /box='Age';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By default the count (n) will have decimals. You can apply a format with n=''*f=f6. or n=''*f=comma6. or similar depening on range of the counts.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Jan 2013 15:38:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2013-01-09T15:38:30Z</dc:date>
    <item>
      <title>Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119079#M32827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have 46 tables created with proc frec on the same variable (age, that is a continous variable going from 0 to 117, with no decimal), but from different files (bd2001-bd2046).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did it this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro loop(year1, year2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %local year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do year = &amp;amp;year1 %to &amp;amp;year2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc freq data=bd.bd&amp;amp;year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend loop;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%loop(2001, 2045);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a new table that would merge those 46 tables and that would looks like this:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 400px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl24" height="17" width="80"&gt;Age&lt;/TD&gt;&lt;TD class="xl24" style="border-left: none;" width="80"&gt;bd2001&lt;/TD&gt;&lt;TD class="xl24" style="border-left: none;" width="80"&gt;bd2002&lt;/TD&gt;&lt;TD class="xl24" style="border-left: none;" width="80"&gt;…&lt;/TD&gt;&lt;TD class="xl24" style="border-left: none;" width="80"&gt;bd2046&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl24" height="17" style="border-top: none;"&gt;0&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl24" height="17" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl24" height="17" style="border-top: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl24" height="17" style="border-top: none;"&gt;…&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl24" height="17" style="border-top: none;"&gt;117&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;&lt;/TD&gt;&lt;TD class="xl24" style="border-top: none; border-left: none;"&gt;##&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I add an out statement with proc freq and merge resulting tables with data set, the problem I meet is that some categories could not fit. For example, if there is no age=52 only for the data set bd2009, then the cell age=53 would take its place and the missing category would be set to age=117. How can I solve this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 01:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119079#M32827</guid>
      <dc:creator>Demographer</dc:creator>
      <dc:date>2013-01-09T01:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119080#M32828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could change how you're doing it...assuming you don't have huge datasets. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do, make sure you're merging using a by statement, by age to allow the merge to happen appropriately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set bd2001-bd2046 indsname=source;&lt;/P&gt;&lt;P&gt;name=scan(source, 2, ".");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=test noprint;&lt;/P&gt;&lt;P&gt;table name*age/out=test2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*then transpose test2...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 01:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119080#M32828</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-09T01:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119081#M32829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or using Reeza's TEST data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc tabulate data=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class age name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table age='',name='' * n=''&lt;/P&gt;&lt;P&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; /box='Age';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By default the count (n) will have decimals. You can apply a format with n=''*f=f6. or n=''*f=comma6. or similar depening on range of the counts.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 15:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119081#M32829</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-01-09T15:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119082#M32830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, but I have very huge dataset and very slow computer. Any other way?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 20:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119082#M32830</guid>
      <dc:creator>Demographer</dc:creator>
      <dc:date>2013-01-09T20:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119083#M32831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't actually show the code that's giving you the issue. If you merge with by statements you shouldn't have that issue. Can you provide the code that's giving the issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 20:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119083#M32831</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-09T20:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119084#M32832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you forgot to add the BY AGE statement after your MERGE statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 20:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119084#M32832</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-01-09T20:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create a personalized table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119085#M32833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I must have missed something here, as I've seen the merge statement mentioned a couple of times, but haven't seen it in any of the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your files are large because they contain variables that aren't needed for the current process, you could use Fareeza's suggested code but only keep the age variable.&amp;nbsp; i.e.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set bd2001-bd2046 (keep=age) indsname=source;&lt;/P&gt;&lt;P&gt;&amp;nbsp; name=scan(source, 2, ".");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=test noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; table age*name/out=test2 (keep= name age count);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=test2&lt;/P&gt;&lt;P&gt;&amp;nbsp; out=want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by age;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; idlabel name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 20:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-personalized-table/m-p/119085#M32833</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-09T20:51:15Z</dc:date>
    </item>
  </channel>
</rss>

