<?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: Proc Freq automatically name output multiple tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889014#M351202</link>
    <description>my orginal data has 35 variables</description>
    <pubDate>Sat, 12 Aug 2023 02:17:48 GMT</pubDate>
    <dc:creator>Anna_DY</dc:creator>
    <dc:date>2023-08-12T02:17:48Z</dc:date>
    <item>
      <title>Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889006#M351196</link>
      <description>&lt;P&gt;I have a simulated dataset with 35 variables (_65, _66,.....,_99) referencing age groups. I'd like to count how many zeros in the data for each age group and get a summary table, so&amp;nbsp; I tried "proc format" as below, however, I don't know how to specify the output files names (after Out &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; :&amp;nbsp; My original thought was to use data step to join all the 35 tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Specifically, my questions are 1) can anyone provide a better way to do this? I guess maybe macro or loop can do this&amp;nbsp; or, 2) follow my current code, to give output dataset names.&lt;/P&gt;&lt;P&gt;Please advise. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;value fmt&lt;BR /&gt;0 = 'Negative'&lt;BR /&gt;other = 'Positive';&lt;BR /&gt;run;&lt;BR /&gt;proc freq data=initial4_64;&lt;BR /&gt;table _65-_99 /out = ;&lt;BR /&gt;format _65-_99 fmt.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 23:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889006#M351196</guid>
      <dc:creator>Anna_DY</dc:creator>
      <dc:date>2023-08-11T23:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889010#M351199</link>
      <description>&lt;P&gt;Here's an earlier question that is similar enough, to point you in the right direction:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-save-proc-freq-result-as-a-table/m-p/347589" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-save-proc-freq-result-as-a-table/m-p/347589&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 01:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889010#M351199</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-08-12T01:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889012#M351200</link>
      <description>&lt;P&gt;&lt;EM&gt;"I have a simulated dataset with 35 variables....&amp;nbsp;My original thought was to use data step to join all the 35 tables"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One table with 35 variables or 35 tables with one variable?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 01:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889012#M351200</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-08-12T01:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889013#M351201</link>
      <description>&lt;P&gt;The older syntax using out= on the tables statement will only send ONE variable to the output set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pray tell, what does a 0 for a variable such as you describe actually mean in terms of analysis? I have a strong suspicion that you have made a choice somewhere that is going to complicate almost any sort of analysis based on ages. And what will you do with 35 data sets of these counts?&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, 12 Aug 2023 01:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889013#M351201</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-12T01:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889014#M351202</link>
      <description>my orginal data has 35 variables</description>
      <pubDate>Sat, 12 Aug 2023 02:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889014#M351202</guid>
      <dc:creator>Anna_DY</dc:creator>
      <dc:date>2023-08-12T02:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889015#M351203</link>
      <description>&lt;P&gt;Thanks for your reply!&amp;nbsp;&lt;/P&gt;&lt;P&gt;In dact I originally tried to run followign code, however, I have 35 variablee (age groups), I was hoping there is a simple way that I could avoid typing these 35 times&lt;BR /&gt;/***count how many of zeros&amp;nbsp; (actually negative which I have recoded as zeros) for each year****/&lt;BR /&gt;proc sql; create table sum_table&lt;BR /&gt;as select distinct sum(case when _66&amp;lt;=0 then 1 else 0 end ) as Neg_66,&lt;BR /&gt;sum (case when _67=0 then 1 else 0 end) as Neg_67,&lt;BR /&gt;sum (case when _68=0 then 1 else 0 end ) as Neg_68,&lt;/P&gt;&lt;P&gt;sum (case when _99=0 then 1 else 0 end ) as Neg_99&lt;/P&gt;&lt;P&gt;from initial3_64;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 02:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889015#M351203</guid>
      <dc:creator>Anna_DY</dc:creator>
      <dc:date>2023-08-12T02:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889016#M351204</link>
      <description>Thanks for your reply, Astounding. I don't think this works</description>
      <pubDate>Sat, 12 Aug 2023 02:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889016#M351204</guid>
      <dc:creator>Anna_DY</dc:creator>
      <dc:date>2023-08-12T02:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889041#M351215</link>
      <description>&lt;P&gt;Lets go back a step, or maybe more than one.&lt;/P&gt;
&lt;P&gt;Describe what your original data looked like before you re-coded anything or possibly even created 35 variables. Better would be to provide a small example of the data , say 10 to 30 records.&lt;/P&gt;
&lt;P&gt;Then tell us the analysis or question that you are attempting to answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This whole bit of creating 35 variables and then wanting 35 data sets is symptomatic of inexperience and perhaps it would help you more to consider choices made earlier. It is not uncommon for new(ish) programmers to attempt to force one or two tools to do everything and get part way through a problem and encounter something that has become awkward to proceed with, such as creating 35 data sets, one for each variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 14:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889041#M351215</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-12T14:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889048#M351219</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446949"&gt;@Anna_DY&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In dact I originally tried to run followign code, however, I have 35 variablee (age groups), I was hoping there is a simple way that I could avoid typing these 35 times&lt;BR /&gt;/***count how many of zeros&amp;nbsp; (actually negative which I have recoded as zeros) for each year****/&lt;BR /&gt;proc sql; create table sum_table&lt;BR /&gt;as select distinct sum(case when _66&amp;lt;=0 then 1 else 0 end ) as Neg_66,&lt;BR /&gt;sum (case when _67=0 then 1 else 0 end) as Neg_67,&lt;BR /&gt;sum (case when _68=0 then 1 else 0 end ) as Neg_68,&lt;/P&gt;
&lt;P&gt;sum (case when _99=0 then 1 else 0 end ) as Neg_99&lt;/P&gt;
&lt;P&gt;from initial3_64;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sounds like you started with two variables. AGE and some YES/NO or Boolean variable, lets call it NEG to match you variable prefix.&amp;nbsp; In that case make a FORMAT to categorize the AGE into your 35 groups, let's call it AGEGRP.&amp;nbsp; Then use it with PROC FREQ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value agegrp
  99 = 'missing'
  0-5 = 'infant'
  6-12 = 'pre-teen'
  12-19 = 'teen'
  20-64= 'adult'
  65-98,100-high = 'elderly'
;
run;
proc freq data=original
  tables age*neg ;
  format age agegrp.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 16:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889048#M351219</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-12T16:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq automatically name output multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889355#M351372</link>
      <description>&lt;P&gt;Thanks, Tom. I think this will work. I just need to transpose my data.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 14:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-automatically-name-output-multiple-tables/m-p/889355#M351372</guid>
      <dc:creator>Anna_DY</dc:creator>
      <dc:date>2023-08-15T14:32:37Z</dc:date>
    </item>
  </channel>
</rss>

