<?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 Dynamic labels process in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670492#M201295</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;The report structure is wide.&lt;/P&gt;
&lt;P&gt;May you show first how to change the structure to long and then to create the wide report with desired labels?&lt;/P&gt;
&lt;P&gt;Nr='Number Customers "&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Income='Total Income'&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It doesn't matter that the report structure is wide. The data itself doesn't have to be wide, it is better off long. And so with a long data set, you can get a wide report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, how do you get the data? Can you explain that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 19 Jul 2020 18:52:58 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-07-19T18:52:58Z</dc:date>
    <item>
      <title>Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670473#M201283</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have the following problem:&lt;/P&gt;
&lt;P&gt;I need to create a report every few days.&lt;/P&gt;
&lt;P&gt;The report have dynamic number of fields.(Depends on business request)&lt;/P&gt;
&lt;P&gt;I want to create a dynamic program that can give labels to columns without typing it manually each run.&lt;/P&gt;
&lt;P&gt;For exaple:&lt;/P&gt;
&lt;P&gt;For each column with name "Nr_Customers"&amp;nbsp; I want to give label "Number Customer in YYMM".&lt;/P&gt;
&lt;P&gt;So for column&amp;nbsp;Nr_Customers2006 the label will be&amp;nbsp; "Number Customer in 2006".&lt;/P&gt;
&lt;P&gt;for column&amp;nbsp;Nr_Customers2005 the label will be&amp;nbsp; "Number Customer in 2005".&lt;/P&gt;
&lt;P&gt;for column&amp;nbsp;Nr_Customers2004 the label will be&amp;nbsp; "Number Customer in 2004".&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to tell SAS that for column&amp;nbsp;"Nr_Customers" SAS will give label&amp;nbsp;"Number Customer" plus "YYMM" that is 4 last digits from column name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data summary:
Input ID Month Nr_Customers2006   Nr_Customers2005 r_Customers2004 Nr_Customers1912  Nr_Customers1812 ;
cards;
1 10 20 30 40 50
2 20 30 40 50 60
3 15 20 25 30 35
4 5 10 15 20 25
5 30 25 20 35 38
;
Run;

Data wanted;
set summary;
label  Nr_Customers2006='Number Customer in 2006'
Nr_Customers2005 ='Number Customer in 2005'
Nr_Customers2004='Number Customer in 2004'
Nr_Customers1912='Number Customer in 1912'
Nr_Customers1812='Number Customer in 1812';
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Jul 2020 16:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670473#M201283</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-19T16:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670477#M201284</link>
      <description>&lt;P&gt;The usual advice is to NOT put yearly (or monthly or calendar) information into separate variables, then you don't need to have calendar information in the variable names, and then you don't need calendar information in variable labels.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Furthermore, just because you want a report with these columns DOES NOT mean you need these columns in a data set. This makes your life much harder. With a long data set (rather than the wide one you are talking about) PROC REPORT &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;easily&lt;/STRONG&gt;&lt;/FONT&gt; makes the report without you ever having to make these columns in a data set with calendar information in their names/labels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input id yymm number;
    cards;
1 2005 28
1 2006 33
1 2007 49
2 2005 38
2 2006 12
2 2007 18
;
proc report data=have;
    columns id yymm,number;
    define id / group "ID";
    define yymm / across "YYMM";
    define number / analysis sum "Number";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Wide data sets are not preferred. Long data sets are preferred. Wide data sets require much more coding. Long data sets require much less coding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maxims 11, 14 and 19.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 17:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670477#M201284</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-19T17:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670482#M201286</link>
      <description>I am sorry but I don't understand your answer.&lt;BR /&gt;The required report included 100 columns for each school.&lt;BR /&gt;The information included statistics for different point of time.&lt;BR /&gt;This is the business requirement.&lt;BR /&gt;Since ,there are groups of columns with same meaning but different time point then I have asked how can I define label for each of them without modifying it manually  in each run.&lt;BR /&gt;For example:&lt;BR /&gt;In the report that I run today there are 4 columns with number of customers :&lt;BR /&gt;Nr_Customers2005&lt;BR /&gt;Nr_Customers2004&lt;BR /&gt;Nr_Customers2001&lt;BR /&gt;Nr_Customers1912&lt;BR /&gt;&lt;BR /&gt;But in the report that I run next week there will be 5 columns:&lt;BR /&gt;Nr_Customers2006&lt;BR /&gt;Nr_Customers2005&lt;BR /&gt;Nr_Customers2004&lt;BR /&gt;Nr_Customers2001&lt;BR /&gt;Nr_Customers1912&lt;BR /&gt;</description>
      <pubDate>Sun, 19 Jul 2020 17:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670482#M201286</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-19T17:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670483#M201287</link>
      <description>&lt;P&gt;If you run the code I provided, you will see what the relevance is to your problem, and you don't have to create the columns with calendar variable names or calendar information in the labels. It is completely dynamic, as the data changes, the columns in the report will change appropriately to match the data.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 17:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670483#M201287</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-19T17:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670484#M201288</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;The report structure is wide.&lt;/P&gt;
&lt;P&gt;May you show first how to change the structure to long and then to create the wide report with desired labels?&lt;/P&gt;
&lt;P&gt;Nr='Number Customers "&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Income='Total Income'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data  summaryTbl;
Input School $  Nr1912 Nr2001  Nr2004 Nr2005 Income1912 Income2001 Income2004 Income2005 ;
cards;
a 10 20 30 40 5 10 15 20
b 12 22 32 42 6 10 18 21
c 20 30 40 50 15 16 18 27
;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 17:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670484#M201288</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-19T17:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670491#M201294</link>
      <description>&lt;P&gt;Moreover,&lt;BR /&gt;In the real report there are 10 "groups" of columns:&lt;BR /&gt;1-Nr_Customers&lt;BR /&gt;2-Income&lt;BR /&gt;3-Revenue&lt;BR /&gt;4-Wage_Cost&lt;BR /&gt;and so on&lt;BR /&gt;Should I perform 10 Proc reports (each one with across ) and then need to join the tables?&lt;BR /&gt;And then what is the benefit???&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 18:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670491#M201294</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-19T18:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670492#M201295</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;The report structure is wide.&lt;/P&gt;
&lt;P&gt;May you show first how to change the structure to long and then to create the wide report with desired labels?&lt;/P&gt;
&lt;P&gt;Nr='Number Customers "&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Income='Total Income'&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It doesn't matter that the report structure is wide. The data itself doesn't have to be wide, it is better off long. And so with a long data set, you can get a wide report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, how do you get the data? Can you explain that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 18:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670492#M201295</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-19T18:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670504#M201298</link>
      <description>Many long reports and then I merge them to have one long report with many  columns of statistical calculations .....Most of statistics are calculated by proc sql with group by  and then we get wide table!</description>
      <pubDate>Sun, 19 Jul 2020 19:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670504#M201298</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-19T19:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670506#M201299</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Many long reports and then I merge them to have one long report with many columns of statistical calculations. Most of statistics are calculated by proc sql with group by and then we get wide table!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So don't do that! Make the data set long, not wide. It doesn't even seem like you need the PROC SQL step. Just take the long data set and run PROC REPORT on it. Whatever statistics are computed by PROC SQL can be computed in PROC REPORT on a long data set producing a wide report.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 10:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670506#M201299</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-20T10:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create Dynamic labels process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670554#M201324</link>
      <description>Then we get wide table?&lt;BR /&gt;&lt;BR /&gt;How? Usually via PROC TRANSPOSE. When you do PROC TRANSPOSE there's the IDLABEL column that you can use to dynamically label your columns I will highly recommend this approach and NOT to rename them after the fact. Why? Because it's less error prone. &lt;BR /&gt;Otherwise you need to design your process for every product/group to ensure you have every value needed. What happens if you're missing a month, for a new product say? From years of doing this, renaming after the fact ASSUMES what the variable label is, but it's easy to find situations that break this, especially when doing it en masse. So use an approach that minimizes your work AND minimizes the likelihood of errors. &lt;BR /&gt;&lt;BR /&gt;If you really, really want to rename after the fact the approach I would use would be to query SASHELP.VCOLUMN and create my labels/variable names and then use PROC DATASETS to rename/relabel it. &lt;BR /&gt;&lt;BR /&gt;I show one approach on how to do that here: &lt;A href="https://gist.github.com/statgeek/f18931085f6a0009185c" target="_blank"&gt;https://gist.github.com/statgeek/f18931085f6a0009185c&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;However, the IDLABEL statement is a better approach.</description>
      <pubDate>Mon, 20 Jul 2020 03:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Dynamic-labels-process/m-p/670554#M201324</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-20T03:09:46Z</dc:date>
    </item>
  </channel>
</rss>

