<?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 report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694458#M211787</link>
    <description>&lt;P&gt;From my perspective, I think your problem is the data structure.&lt;/P&gt;
&lt;P&gt;Most reporting made is easier and syntax more data driven if you have long data sets (transpose columns to rows).&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2020 09:02:37 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2020-10-27T09:02:37Z</dc:date>
    <item>
      <title>Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694440#M211778</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create proc report.&lt;/P&gt;
&lt;P&gt;There are many varaibles that I want to write in define statement.&lt;/P&gt;
&lt;P&gt;What is the clever way to write them using macro/array in the define statement instead of typing many rows?&lt;/P&gt;
&lt;P&gt;Please note that I have the list of the varaible in&amp;nbsp; a macro varaible called vector&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data example;
input Subject mon_1701 mon_1702 mon_1703 mon_1704 mon_1705 mon_1706
              mon_1707 mon_1708 mon_1709 mon_1710 mon_1711 mon_1712
              mon_1801 mon_1802 mon_1803 mon_1804 mon_1805 mon_1806
              mon_1807 mon_1808 mon_1809 mon_1810 mon_1811 mon_1812
;
cards;
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
2 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
;
run;

%let vector=mon_1701 mon_1702 mon_1703 mon_1704 mon_1705 mon_1706 
mon_1707 mon_1708 mon_1709 mon_1710 mon_1711 mon_1712
mon_1801 mon_1802 mon_1803 mon_1804 mon_1805 mon_1806 
mon_1807 mon_1808 mon_1809 mon_1810 mon_1811 mon_1812;

%let K_Vector=24;

proc report data=example nowd;
column  Subject
mon_1701 mon_1702 mon_1703 mon_1704 mon_1705 mon_1706
mon_1707 mon_1708 mon_1709 mon_1710 mon_1711 mon_1712
mon_1801 mon_1802 mon_1803 mon_1804 mon_1805 mon_1806
mon_1807 mon_1808 mon_1809 mon_1810 mon_1811 mon_1812
;
define Subject / display  'Subject #';
define mon_1701 / display ;
define mon_1702/ display  ;
.................
.................
define mon_1812/ display  ;
Run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;/****My try to do it*/&lt;BR /&gt;/****My try to do it*/&lt;BR /&gt;/****My try to do it*/&lt;BR /&gt;%let vector=mon_1701 mon_1702 mon_1703 mon_1704 mon_1705 mon_1706&lt;BR /&gt;mon_1707 mon_1708 mon_1709 mon_1710 mon_1711 mon_1712&lt;BR /&gt;mon_1801 mon_1802 mon_1803 mon_1804 mon_1805 mon_1806&lt;BR /&gt;mon_1807 mon_1808 mon_1809 mon_1810 mon_1811 mon_1812;&lt;BR /&gt;%put &amp;amp;vector;&lt;/P&gt;
&lt;P&gt;proc report data=example nowd;&lt;BR /&gt;column Subject &amp;amp;vector;&lt;BR /&gt;define _all_;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 09:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694440#M211778</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-10-27T09:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694458#M211787</link>
      <description>&lt;P&gt;From my perspective, I think your problem is the data structure.&lt;/P&gt;
&lt;P&gt;Most reporting made is easier and syntax more data driven if you have long data sets (transpose columns to rows).&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 09:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694458#M211787</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2020-10-27T09:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694463#M211790</link>
      <description>&lt;P&gt;Use a long layout:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subject $ mon $ value;
datalines;
A 1701 5
A 1702 7
B 1701 3
B 1702 4
;

proc report data=have;
column subject mon,value;
define subject / group;
define mon /across;
define value / display sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As always, a long layout makes the coding dead simple.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 09:35:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694463#M211790</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-27T09:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694488#M211807</link>
      <description>&lt;P&gt;Aggreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;, a long data set would make this simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;, we have discussed this in at least three previous threads, where you were advised to create long rather than wide data sets.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Dynamic-Report-with-non-fix-number-of-columns-and-task-to-create/m-p/672346" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Dynamic-Report-with-non-fix-number-of-columns-and-task-to-create/m-p/672346&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/proc-report-How-to-write-shorter-code/m-p/671366#M201596" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/proc-report-How-to-write-shorter-code/m-p/671366#M201596&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670504#M201298" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670504#M201298&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I urge you to embrace the idea of using long data sets in this situation instead of ignoring it.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 10:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694488#M211807</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-27T10:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694619#M211846</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;From my perspective, I think your problem is the data structure.&lt;/P&gt;
&lt;P&gt;Most reporting made is easier and syntax more data driven if you have long data sets (transpose columns to rows).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Been telling the OP that for a couple years now.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 15:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694619#M211846</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-27T15:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694628#M211848</link>
      <description>&lt;P&gt;Since they all start with the same string you can just use one DEFINE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define mon_: / display ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Oct 2020 16:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694628#M211848</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-27T16:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694748#M211897</link>
      <description>&lt;P&gt;You are the best!&lt;/P&gt;
&lt;P&gt;This is the solution!&lt;/P&gt;
&lt;P&gt;I understand that in such case better structure is long and not wide.&lt;/P&gt;
&lt;P&gt;However, in this case I receive a data set with wide structure and from this structure I need to create the desired report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am writing again the solution that you sent.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data example;
input Subject mon_1701 mon_1702 mon_1703 mon_1704 mon_1705 mon_1706
              mon_1707 mon_1708 mon_1709 mon_1710 mon_1711 mon_1712
              mon_1801 mon_1802 mon_1803 mon_1804 mon_1805 mon_1806
              mon_1807 mon_1808 mon_1809 mon_1810 mon_1811 mon_1812
;
cards;
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
2 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
;
run;


%let K_Vector=24;
proc report data=example nowd;
column  Subject
mon_1701 mon_1702 mon_1703 mon_1704 mon_1705 mon_1706
mon_1707 mon_1708 mon_1709 mon_1710 mon_1711 mon_1712
mon_1801 mon_1802 mon_1803 mon_1804 mon_1805 mon_1806
mon_1807 mon_1808 mon_1809 mon_1810 mon_1811 mon_1812
;
define Subject / display  'Subject #';
define mon_: / display ;
Run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 07:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694748#M211897</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-10-28T07:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694759#M211900</link>
      <description>&lt;P&gt;The first step in any work process should be "make your work easier". So you reduce data in observations and columns to only keep what's needed; or (like I do) you first format the code you get so that it is easier to read and work with. Likewise,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;However, in this case I receive a data set with wide structure&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;in such a case you first convert to a better structure; this work upfront reduces the time needed later, and the gains usually outweigh the effort you invested at the beginning.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 08:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694759#M211900</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-28T08:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694809#M211932</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;in such a case you first convert to a better structure; this work upfront reduces the time needed later, and the gains usually outweigh the effort you invested at the beginning.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Great advice! Maybe it should be a maxim! (Or a sub-maxim under 19)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 11:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694809#M211932</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-28T11:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694813#M211933</link>
      <description>&lt;P&gt;Allow me to point out that the problem with the solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define mon_:/display;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is that it does not create nicely labelled columns. The first column will be labelled mon_1701. If you'd prefer to have the column labelled as January 2017 or 01/17 or anything like that, then this means you'd have to return to naming all the columns individually in their own DEFINE statement (or better yet, use a long data set). Sometimes, maybe the naming of columns isn't important, especially if only you are going to view the results; but any time you want to share this result with others, I always provide meaningful names/labels to my columns, as it looks much more professional and results in fewer questions.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 11:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694813#M211933</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-28T11:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report with many like named columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694818#M211937</link>
      <description>&lt;P&gt;Given the fact that I will retire in 2022 (and if SASGF in San Diego happens, I'll be there as a "retirement gift" to myself!!), it may well be that I spend part of my time making a SAS book out of the Maxims, with a chapter for each. That will allow me to elaborate on each maxim in a much wider sense.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 12:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-with-many-like-named-columns/m-p/694818#M211937</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-28T12:05:41Z</dc:date>
    </item>
  </channel>
</rss>

