<?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: Building reports &amp; grouping variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13891#M1736</link>
    <description>I meant I wanted the actual values to be displayed instead of number or counts</description>
    <pubDate>Wed, 05 May 2010 19:29:21 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-05-05T19:29:21Z</dc:date>
    <item>
      <title>Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13886#M1731</link>
      <description>Hi All,&lt;BR /&gt;
I am trying to build a sas report where I need to group affiliation codes and present all of them in a single row.&lt;BR /&gt;
For example&lt;BR /&gt;
my data set contain the following fields&lt;BR /&gt;
ID name affliation_name&lt;BR /&gt;
1   XYZ   abc&lt;BR /&gt;
1   XYZ   cde&lt;BR /&gt;
2   LMN  abc&lt;BR /&gt;
2   LMN  cde&lt;BR /&gt;
2   LMN  ijk&lt;BR /&gt;
3   RST  cde&lt;BR /&gt;
3   RST  ijk&lt;BR /&gt;
&lt;BR /&gt;
I need it to be transformed like this&lt;BR /&gt;
ID name affiliation_name1  affiliation_name2  affiliation_name3&lt;BR /&gt;
1  XYZ      abc                   cde&lt;BR /&gt;
2  LMN     abc                   cde                         ijk&lt;BR /&gt;
3  RST                              cde                         ijk     &lt;BR /&gt;
&lt;BR /&gt;
Also the affiliation name should be renamed to 123  456  789&lt;BR /&gt;
I know I can use proc transpose but with this the first affiliation name would go into the first affiliation field. Any ideas.</description>
      <pubDate>Fri, 30 Apr 2010 20:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13886#M1731</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-30T20:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13887#M1732</link>
      <description>You can prepare (sort) your data first then TRANSPOSE or TRANSPOSE and then format your data, if you are concerned about the SAS-generated variable order.  Otherwise it's unclear to me what you mean by "the first affiliation name would go into the first affiliation field."&lt;BR /&gt;
&lt;BR /&gt;
If you have made an attempt, by all means, share your code and the undesirable results, for forum subscriber feedback and guidance.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 30 Apr 2010 20:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13887#M1732</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-30T20:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13888#M1733</link>
      <description>Here is my data set Aff_name1&lt;BR /&gt;
ID  name Affiliation_name&lt;BR /&gt;
1   abc    ATT&lt;BR /&gt;
1   abc    Tmobile&lt;BR /&gt;
1   abc    verizon&lt;BR /&gt;
2   def    ATT&lt;BR /&gt;
2   def   Tmobile&lt;BR /&gt;
3   ghi   Verizon&lt;BR /&gt;
&lt;BR /&gt;
When I do proc transpose data = Aff_name1 out = Aff_name2;&lt;BR /&gt;
by ID  name ;&lt;BR /&gt;
var Affiliation_name;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
It returns me the following output file Aff_name2&lt;BR /&gt;
ID name Col1  Col2      Col3&lt;BR /&gt;
1  abc    ATT  Tmobile  Verizon   &lt;BR /&gt;
2  def     ATT  Tmobile&lt;BR /&gt;
3  ghi     Verizon&lt;BR /&gt;
&lt;BR /&gt;
Instead I want the output as&lt;BR /&gt;
ID name Col1  Col2      Col3&lt;BR /&gt;
1  abc    ATT  Tmobile  Verizon   &lt;BR /&gt;
2  def     ATT  Tmobile&lt;BR /&gt;
3  ghi                          Verizon&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions on how I can limit which value needs to go into which column.&lt;BR /&gt;
Thanks,&lt;BR /&gt;
APS</description>
      <pubDate>Wed, 05 May 2010 17:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13888#M1733</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-05T17:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13889#M1734</link>
      <description>Hi:&lt;BR /&gt;
  Somehow, I think the indenting that you want to use is getting lost in the forum posting mechanism. For more information on how to post code and maintain indenting in future posts, this is useful information:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=27609毙" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=27609毙&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
What I think you're saying is that you are getting this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ID name  Col1     Col2     Col3&lt;BR /&gt;
 1  abc  ATT      Tmobile  Verizon &lt;BR /&gt;
 2  def  ATT      Tmobile&lt;BR /&gt;
 3  ghi  Verizon&lt;BR /&gt;
[/pre]&lt;BR /&gt;
            &lt;BR /&gt;
with "mixed" information in the COL1 variable and that's not what you want.&lt;BR /&gt;
       &lt;BR /&gt;
I think you mean that you &lt;B&gt;want&lt;/B&gt; this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ID name Col1     Col2     Col3&lt;BR /&gt;
 1  abc ATT      Tmobile  Verizon &lt;BR /&gt;
 2  def ATT      Tmobile&lt;BR /&gt;
 3  ghi                   Verizon&lt;BR /&gt;
[/pre]&lt;BR /&gt;
              &lt;BR /&gt;
So that COL1 is ALWAYS ATT and COL2 is ALWAYS Tmobile and COL3 is ALWAYS Verizon. Is that what you mean???&lt;BR /&gt;
 &lt;BR /&gt;
Is the above the report you want or is it the structure of the dataset that you want? Generally, if you wanted to see a report grouped in such a way (so that the Affiliation_name values were going across the top of the report), you might use PROC TABULATE or PROC REPORT and then in the cells underneath the Affiliation_name, you might see some number, such as a count, a percent or some other statistic, such as number of customers, amount of sales, number of minutes, etc. Simple counts (the N statistic) are shown in the program below without using PROC TRANSPOSE.&lt;BR /&gt;
           &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data mydata;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input ID name $ Affiliation_name $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 abc ATT&lt;BR /&gt;
1 abc Tmobile&lt;BR /&gt;
1 abc Verizon&lt;BR /&gt;
2 def ATT&lt;BR /&gt;
2 def Tmobile&lt;BR /&gt;
3 ghi Verizon&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                            &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc tabulate data=mydata f=comma8.;&lt;BR /&gt;
  class name affiliation_name;&lt;BR /&gt;
  table name all,&lt;BR /&gt;
        affiliation_name all;&lt;BR /&gt;
run;&lt;BR /&gt;
                        &lt;BR /&gt;
proc report data=mydata nowd;&lt;BR /&gt;
  column name (affiliation_name,n) n;&lt;BR /&gt;
  define name / group;&lt;BR /&gt;
  define affiliation_name / across;&lt;BR /&gt;
  define n / f=comma8.;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 05 May 2010 18:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13889#M1734</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-05-05T18:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13890#M1735</link>
      <description>Yeah you have decsribed correctly what I want in the out put. I want instead on number or counts. Can you please advise on how to do that.</description>
      <pubDate>Wed, 05 May 2010 19:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13890#M1735</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-05T19:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13891#M1736</link>
      <description>I meant I wanted the actual values to be displayed instead of number or counts</description>
      <pubDate>Wed, 05 May 2010 19:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13891#M1736</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-05T19:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Building reports &amp; grouping variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13892#M1737</link>
      <description>Hi:&lt;BR /&gt;
  Probably the most straightforward way to do what you want is to use a DATA step program and ARRAY processing to create the variables in a dataset in the order you want. One quick thing to do might be to use an INFORMAT to determine the proper column "number"...something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  invalue aff 'ATT' = 1&lt;BR /&gt;
              'Tmobile' = 2&lt;BR /&gt;
              'Verizon' = 3&lt;BR /&gt;
              other = .;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                     &lt;BR /&gt;
And then, in your program, you could set an index variable using the INFORMAT like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  j = put(affiliation_name, aff.);&lt;BR /&gt;
                    &lt;BR /&gt;
  array_name(j) = affiliation_name;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                              &lt;BR /&gt;
In the above code snippet, the variable J will take on the value of 1, 2 or 3, depending on the defined informat values. Then the reference &lt;B&gt;array_name(j)&lt;/B&gt; assumes that you are using an array referencing technique to assign the current observation's value for AFFILIATION_NAME to the correct array variable.&lt;BR /&gt;
 &lt;BR /&gt;
You would also need to use BY group processing and FIRST. and LAST. variables in order to make sure that you only output one observation at the end of the group and that you initialized the new array variables to blanks at the beginning of each new group.&lt;BR /&gt;
 &lt;BR /&gt;
For more information about array processing and to learn about how to write a DATA step program that uses arrays, refer to some of these papers or documentation topics:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=13408㑠" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=13408㑠&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/242-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/242-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p066-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p066-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi24/Posters/p215-24.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi24/Posters/p215-24.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/155-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/155-2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi24/Advtutor/p48-24.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi24/Advtutor/p48-24.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002299816.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002299816.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 06 May 2010 00:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-reports-grouping-variables/m-p/13892#M1737</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-05-06T00:47:36Z</dc:date>
    </item>
  </channel>
</rss>

