<?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: Using proc summary how can I flatten data? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757777#M30159</link>
    <description>No, but you can use PROC REPORT, TABULATE or wrangle the data after the fact. It depends on what exactly you need going to a text file.&lt;BR /&gt;&lt;BR /&gt;Can we assume you're familiar with ODS and passing your results directly to an Excel, PDF or Word file? &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 28 Jul 2021 16:17:11 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-07-28T16:17:11Z</dc:date>
    <item>
      <title>Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757774#M30158</link>
      <description>&lt;P&gt;Hi I have some data that I am using proc summary to tidy up so I can output it as a text file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having some issues, for the text file they want both male and female counts on the same line, however when using proc summary when I use the variable gender in the class statement it separates them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;summary&lt;/STRONG&gt; data=undup nway;&lt;/P&gt;&lt;P&gt;class&amp;nbsp; gender Class Ethnic ;&lt;/P&gt;&lt;P&gt;var count;&lt;/P&gt;&lt;P&gt;format Ethnic $ethnic.;&lt;/P&gt;&lt;P&gt;output out=undupFinal sum=;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like the format that proc summary gives me but I would like to be able to have both the male count and female count on the same line. Is there a way to do this with proc summary?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757774#M30158</guid>
      <dc:creator>helloagainoh2</dc:creator>
      <dc:date>2021-07-28T16:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757777#M30159</link>
      <description>No, but you can use PROC REPORT, TABULATE or wrangle the data after the fact. It depends on what exactly you need going to a text file.&lt;BR /&gt;&lt;BR /&gt;Can we assume you're familiar with ODS and passing your results directly to an Excel, PDF or Word file? &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757777#M30159</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-28T16:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757780#M30160</link>
      <description>&lt;P&gt;It's not clear why you would want them both on one line, but in general, the idea of converting a long data set (which is what PROC SUMMARY gives you) into a much wider data set where everything is on one line, is generally considered to be poor practice, and makes your coding much more difficult. See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 19&lt;/A&gt;, Long beats Wide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So why do you want this? What are you going to do with this wide and flat data that you can't do with the actual PROC SUMMARY output?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757780#M30160</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-28T16:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757786#M30161</link>
      <description>&lt;P&gt;Yes I am familiar with ODS and outputting to PDF and Excel. I inherited this program and the previous coder used proc summary to group and aggregate the data by categories and then output it to a text file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They didn't need to report different counts for genders at the time so I am not sure proc summary is the best way forward. I am realizing that I need to have one line with counts for the different combinations of gender and ethnicity.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output needs to be in a certain format, so for example the output would be a number for white females that starts at column 35 and the output for Hispanic men would be a number at column 53 on the text file.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757786#M30161</guid>
      <dc:creator>helloagainoh2</dc:creator>
      <dc:date>2021-07-28T16:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757790#M30162</link>
      <description>&lt;P&gt;It's for an automated service that reads the text file for verification, they want the data on the text file outputted on certain columns at certain lengths.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757790#M30162</guid>
      <dc:creator>helloagainoh2</dc:creator>
      <dc:date>2021-07-28T16:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757793#M30163</link>
      <description>Yeah, then you may as well wrangle the output from PROC SUMMARY. I would take a look at some of the macros JeffMyers has provided in the Community Library if you want tables that are a little more structured or to help get it in a format automatically but I trust that you're capable of figuring out a PROC TRANSPOSE as well.</description>
      <pubDate>Wed, 28 Jul 2021 16:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757793#M30163</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-28T16:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757807#M30164</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/364863"&gt;@helloagainoh2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes I am familiar with ODS and outputting to PDF and Excel. I inherited this program and the previous coder used proc summary to group and aggregate the data by categories and then output it to a text file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They didn't need to report different counts for genders at the time so I am not sure proc summary is the best way forward. I am realizing that I need to have one line with counts for the different combinations of gender and ethnicity.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output needs to be in a certain format, so for example the output would be a number for white females that starts at column 35 and the output for Hispanic men would be a number at column 53 on the text file.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It may help to provide the full description of the text file.&lt;/P&gt;
&lt;P&gt;When specific columns positions are needed that quite often calls for a Data step to full control and might require transposing the output from Summary before creating the output text file.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 17:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757807#M30164</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-28T17:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc summary how can I flatten data?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757968#M30167</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/364863"&gt;@helloagainoh2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes I am familiar with ODS and outputting to PDF and Excel. I inherited this program and the previous coder used proc summary to group and aggregate the data by categories and then output it to a text file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They didn't need to report different counts for genders at the time so I am not sure proc summary is the best way forward. I am realizing that I need to have one line with counts for the different combinations of gender and ethnicity.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output needs to be in a certain format, so for example the output would be a number for white females that starts at column 35 and the output for Hispanic men would be a number at column 53 on the text file.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No need to convert the data before writing the text file.&lt;/P&gt;
&lt;P&gt;Say you have a variable GROUP, SEX, RACE and COUNT and the data is sorted by GROUP then you can write all of the values for the same group to the same line.&amp;nbsp; Just use the trailing&amp;nbsp;@ on the PUT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;
  by group;
  file 'myfile.txt';
  ...
  if sex='FEMALE' and RACE='WHITE' then put @35 count @;
  ...
  if last.group then put;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Jul 2021 00:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-proc-summary-how-can-I-flatten-data/m-p/757968#M30167</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-29T00:23:15Z</dc:date>
    </item>
  </channel>
</rss>

