<?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 new variables based on observations to statistics in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459997#M116887</link>
    <description>&lt;P&gt;you&amp;nbsp;can create table with history data automatically using macro vars, but I am not sure if this is what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below program will get you the past 4 years data automatically if you mention the source data and date field i.e required to check.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'dt'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,put(intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'day'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,today(),&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmyy7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'dtb4y'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,put(intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'year'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,today(),-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmyy7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dt=&amp;amp;dt.;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dtb4y=&amp;amp;dtb4y.;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; actual_date between &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;dtb4y."d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; and &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;dt."d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 May 2018 10:59:14 GMT</pubDate>
    <dc:creator>Vish33</dc:creator>
    <dc:date>2018-05-04T10:59:14Z</dc:date>
    <item>
      <title>Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459970#M116871</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function transpose we don't have control on creation new variables, like name or create only new variables and organize them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i have is a table with a date refer to a name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.Add_columns;
  input Nome:$300. Mes:$300.;
datalines4;
Joao 06M2017
Pedro 03M2016
Andre 05M2015
Miguel 01M2017
Jose 02M2016
Joao 03M2015
Pedro 05M2017
Andre 08M2014
Jose 12M2017
Jose 02M2016
Jose 02M2017
Joao 06M2017
Joao 06M2017
Joao 06M2017
Andre 05M2015
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want is a table like that. Organize for Month/Year in&amp;nbsp;FORMAT=MMYY7.&lt;/P&gt;&lt;P&gt;It was dificult to understand how to do that in SAS. How to create new columns automatic with the observations values. I think the best is in a macro. One problem is how to create a new column and not a repeated column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08M2014 03M2015 05M2015 02M2016 03M2016 01M2017 02M2017 05M2017 06M2017 12M2017&amp;nbsp;&lt;BR /&gt;Joao&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;Pedro&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;Andre&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;Miguel&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;Jose&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Aleixo&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 09:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459970#M116871</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-05-04T09:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459973#M116874</link>
      <description>&lt;P&gt;The reason its difficult to do is because it is a&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;very bad idea&lt;/STRONG&gt;&lt;/U&gt;.&amp;nbsp; Variable names should be simple and easy to program with.&amp;nbsp; Giving them the names of dates - which are an abstract concept anyways - will make your programming life a nightmare.&amp;nbsp; In the worse case scenario, transpose the data up and give the variable names something like var, then apply the date as the label.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being said, I really would not go for that data structure at all.&amp;nbsp; From data which is 15*2 datapoints, you are going with a 10*5 datapoints, so effectively creating 20 datapoints with no information - bad for storage, bad for processing.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 09:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459973#M116874</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T09:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459979#M116880</link>
      <description>&lt;P&gt;The main idea is create a table with a statistics monthly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This data is an example. The real life is different and not many zeros will appear in that statistic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok a little bit different i can modify to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- How to create a table automatic with columns Month/Year? For example for 4 ou 5 years sequentially based on today date to past dates?.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- After that creation i can update the values in that month/year&amp;nbsp; for each name, because with freq function give me the values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a good idea?&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/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;Thanks your answer&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 09:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459979#M116880</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-05-04T09:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459980#M116881</link>
      <description>&lt;P&gt;I really wouldn't recommend it.&amp;nbsp; Unless its for an output report (in which case tranpsoe before the report, or use an across statement), using normalised - data going down - is far easier to work with, smaller, and expandable endlessly.&amp;nbsp; E.g&lt;/P&gt;
&lt;P&gt;MonthYear&amp;nbsp; &amp;nbsp; Statistic&amp;nbsp; &amp;nbsp;Result&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This dataset, you can very easily add data to , filter the data, add other statistics, sort etc.&amp;nbsp; Try to do any of that with data going across, where you would need to find out what the variables are called, then loop across them, likely with big complicated messy macro code and arrays.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459980#M116881</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T10:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459987#M116883</link>
      <description>&lt;P&gt;Transpose wouldn't work as you have multiple same ID columns and would need unique value for ID column. But this can be done with cross-tabulation report with proc tabulate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;tabulate&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=WORK.Add_columns;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;class&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mes name;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;tables&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; name=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,mes=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * n=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;misstext&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'0'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="croos tab.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20368iAF6C4C2361E44D99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="croos tab.JPG" alt="croos tab.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Vish&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459987#M116883</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2018-05-04T10:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459993#M116884</link>
      <description>&lt;P&gt;Very good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is possible to convert&amp;nbsp;report to a sas7bdat? Or via excel and after convert to sas7bdat?&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459993#M116884</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-05-04T10:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459995#M116885</link>
      <description>&lt;P&gt;yes, we can transpose the tabulate output to get the sas dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;tabulate&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=WORK.Add_columns &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;class&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mes name;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;tables&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; name=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,mes=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * n=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;misstext&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'0'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=want &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=want1(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=_name_);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; n;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;id&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mes;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; name;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459995#M116885</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2018-05-04T10:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459997#M116887</link>
      <description>&lt;P&gt;you&amp;nbsp;can create table with history data automatically using macro vars, but I am not sure if this is what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below program will get you the past 4 years data automatically if you mention the source data and date field i.e required to check.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'dt'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,put(intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'day'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,today(),&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmyy7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'dtb4y'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,put(intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'year'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,today(),-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmyy7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dt=&amp;amp;dt.;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dtb4y=&amp;amp;dtb4y.;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; actual_date between &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;dtb4y."d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; and &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;dt."d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/459997#M116887</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2018-05-04T10:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/460002#M116888</link>
      <description>&lt;P&gt;Thanks your answer i will see that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to question but the columns don't are organize by date. Variable is a format date and after tabulate function pass to numeric.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: Could be done if my date has this format yearmonth, like 201701, 201702, 201703&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 11:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/460002#M116888</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-05-04T11:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/460006#M116890</link>
      <description>&lt;P&gt;sort the date field "mes" in ascending order before transpose . this should give dates in sequence.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 11:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/460006#M116890</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2018-05-04T11:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables based on observations to statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/460014#M116894</link>
      <description>&lt;P&gt;yes that's what i did.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 12:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-based-on-observations-to-statistics/m-p/460014#M116894</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-05-04T12:35:16Z</dc:date>
    </item>
  </channel>
</rss>

