<?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: How to transform that into a macro (where one can choose what he want to see) ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77667#M16826</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello and thanks guys&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm doing this on EG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah I understand that getting all the variables in first place is very not optimal. Then my problem would be to specify which variable to collect (i.e. here from 24 quarters) in one table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides, I also need it to be automatised as the user can choose the length of the period (about starting and ending quarter)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Sep 2013 14:48:44 GMT</pubDate>
    <dc:creator>GuiVtzl</dc:creator>
    <dc:date>2013-09-10T14:48:44Z</dc:date>
    <item>
      <title>How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77664#M16823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the last episode of my fantastic saga (ahah)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I've got a period from 2007Q2 to 2013Q2, so 24 quarters&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 24 tables (one per quarter) with the column ID (clients) and some quantitative variables (let say quantities, people etc.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the column ID is the same for the 24 tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do is this (see my code below) but inside a macro, knowing that the period is determined via prompts that user chooses (YearStart YearEnd QuarterStart QuarterEnd). So what I did below is clearly not good as I have to manually write&amp;nbsp; the quarters etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides, a prompt is also used here (variable) with which the user chooses what variable he wants to see in the final table (Rating or EAD).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CREATE TABLE CREDITR.HISTO_RATINGS2 AS &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SELECT t1.Client, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.CD_COTATION&amp;nbsp; AS RATING_Q3_07, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.CD_COTATION&amp;nbsp; AS RATING_Q4_07, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t3.CD_COTATION&amp;nbsp; AS RATING_Q1_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t4.CD_COTATION&amp;nbsp; AS RATING_Q2_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t5.CD_COTATION&amp;nbsp; AS RATING_Q3_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t6.CD_COTATION&amp;nbsp; AS RATING_Q4_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t7.CD_COTATION&amp;nbsp; AS RATING_Q1_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t8.CD_COTATION&amp;nbsp; AS RATING_Q2_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t9.CD_COTATION&amp;nbsp; AS RATING_Q3_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t10.CD_COTATION&amp;nbsp; AS RATING_Q4_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t11.CD_COTATION&amp;nbsp; AS RATING_Q1_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t12.CD_COTATION&amp;nbsp; AS RATING_Q2_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t13.CD_COTATION&amp;nbsp; AS RATING_Q3_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t14.CD_COTATION&amp;nbsp; AS RATING_Q4_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t15.CD_COTATION&amp;nbsp; AS RATING_Q1_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t16.CD_COTATION&amp;nbsp; AS RATING_Q2_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t17.CD_COTATION&amp;nbsp; AS RATING_Q3_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t18.CD_COTATION&amp;nbsp; AS RATING_Q4_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t19.CD_COTATION&amp;nbsp; AS RATING_Q1_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t20.CD_COTATION&amp;nbsp; AS RATING_Q2_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t21.CD_COTATION&amp;nbsp; AS RATING_Q3_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t22.CD_COTATION&amp;nbsp; AS RATING_Q4_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t23.CD_COTATION&amp;nbsp; AS RATING_Q1_13, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t24.CD_COTATION&amp;nbsp; AS RATING_Q2_13,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.EAD&amp;nbsp; AS EAD_Q3_07, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.EAD&amp;nbsp; AS EAD_Q4_07, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t3.EAD&amp;nbsp; AS EAD_Q1_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t4.EAD&amp;nbsp; AS EAD_Q2_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t5.EAD&amp;nbsp; AS EAD_Q3_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t6.EAD&amp;nbsp; AS EAD_Q4_08, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t7.EAD&amp;nbsp; AS EAD_Q1_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t8.EAD&amp;nbsp; AS EAD_Q2_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t9.EAD&amp;nbsp; AS EAD_Q3_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t10.EAD&amp;nbsp; AS EAD_Q4_09, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t11.EAD&amp;nbsp; AS EAD_Q1_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t12.EAD&amp;nbsp; AS EAD_Q2_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t13.EAD&amp;nbsp; AS EAD_Q3_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t14.EAD&amp;nbsp; AS EAD_Q4_10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t15.EAD&amp;nbsp; AS EAD_Q1_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t16.EAD&amp;nbsp; AS EAD_Q2_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t17.EAD&amp;nbsp; AS EAD_Q3_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t18.EAD&amp;nbsp; AS EAD_Q4_11, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t19.EAD&amp;nbsp; AS EAD_Q1_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t20.EAD&amp;nbsp; AS EAD_Q2_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t21.EAD&amp;nbsp; AS EAD_Q3_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t22.EAD&amp;nbsp; AS EAD_Q4_12, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t23.EAD&amp;nbsp; AS EAD_Q1_13, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t24.EAD&amp;nbsp; AS EAD_Q2_13&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM CREDITR.RATINGS1 t1, CREDITR.RATINGS2 t2, CREDITR.RATINGS3 t3, CREDITR.RATINGS4 t4, CREDITR.RATINGS5 t5, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS6 t6, CREDITR.RATINGS7 t7, CREDITR.RATINGS8 t8, CREDITR.RATINGS9 t9, CREDITR.RATINGS10 t10, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS11 t11, CREDITR.RATINGS12 t12, CREDITR.RATINGS13 t13, CREDITR.RATINGS14 t14, CREDITR.RATINGS15 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t15, CREDITR.RATINGS16 t16, CREDITR.RATINGS17 t17, CREDITR.RATINGS18 t18, CREDITR.RATINGS19 t19, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS20 t20, CREDITR.RATINGS21 t21, CREDITR.RATINGS22 t22, CREDITR.RATINGS23 t23, CREDITR.RATINGS24 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE (t1.Client = t2.Client AND t1.Client = t3.Client AND t1.Client = t4.Client AND t1.Client = t5.Client AND &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Client = t6.Client AND t1.Client = t7.Client AND t1.Client = t8.Client AND t1.Client = t9.Client AND &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Client = t10.Client AND t1.Client = t11.Client AND t1.Client = t12.Client AND t1.Client = t13.Client AND &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Client = t14.Client AND t1.Client = t15.Client AND t1.Client = t16.Client AND t1.Client = t17.Client AND &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Client = t18.Client AND t1.Client = t19.Client AND t1.Client = t20.Client AND t1.Client = t21.Client AND &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Client = t22.Client AND t1.Client = t23.Client AND t1.Client = t24.Client);&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA CREDITR.HISTO_RATINGS2 ; SET CREDITR.HISTO_RATINGS2 (keep=&amp;amp;variable:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 13:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77664#M16823</guid>
      <dc:creator>GuiVtzl</dc:creator>
      <dc:date>2013-09-10T13:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77665#M16824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What environment do you want this in? Enterprise Guide, Base SAS, AF / FSP or something else?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 14:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77665#M16824</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-09-10T14:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77666#M16825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I probably dont understand the end use case well enough but based on the information in the post it seems like making the data wider will make the problem harder. Appending the data together and specifying a new date variable based on the dataset the information is coming from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could reduce the number of date prompts as well to just start YR Q and end YR Q.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like I said if Im off base on the use case this may not make sense .... just throwing it out there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 14:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77666#M16825</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-09-10T14:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77667#M16826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello and thanks guys&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm doing this on EG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah I understand that getting all the variables in first place is very not optimal. Then my problem would be to specify which variable to collect (i.e. here from 24 quarters) in one table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides, I also need it to be automatised as the user can choose the length of the period (about starting and ending quarter)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 14:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77667#M16826</guid>
      <dc:creator>GuiVtzl</dc:creator>
      <dc:date>2013-09-10T14:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77668#M16827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi GuiVtzl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This can be done in many ways depending on what parameters your users wish to enter. E.g. either only a number of quarters backtracking from today (one parameter), a start date and number of quarters (2 params) a start date and end date (2 param) etc. etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As one example of how you could macro this with 4 parameters: start date/end date and quarters since that's what you've mentioned up top (I would've opted for a YYQ4 syntax 2 parameter input personally as it felt more natural). For simplicity at the moment, this assumes that no year before 2000 might be queried. If so, I would recommend using 4 digit year inputs instead to not cause a bunch of special handling for substractions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* user must enter start date and end dates using the YYQ4 syntax e.g. 07Q3 13Q2 */&lt;/P&gt;&lt;P&gt;%macro histo_rating(startY=, startQ=, endY=, endQ=, desiredvar=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let qspan = %eval(&amp;nbsp; (&amp;amp;endy.-&amp;amp;starty.-1)*4) + (4-&amp;amp;startQ.+1) + &amp;amp;endq.);&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;qspan.; /*create indexed macro variables to simplify looping */&lt;/P&gt;&lt;P&gt;%let Q&amp;amp;i. = %sysfunc(putn(%sysfunc(mod(&amp;amp;startQ.+&amp;amp;i.-1, 4)), z1.));&lt;/P&gt;&lt;P&gt;%let Y&amp;amp;i. = %sysfunc(putn(%eval(&amp;amp;startY.+%sysfunc(floor(((&amp;amp;startQ.+&amp;amp;i.-1)-1)/4))), z2.));&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table creditr.histo_ratings_&amp;amp;startY.Q&amp;amp;startQ._to_&amp;amp;endY.Q&amp;amp;endQ. as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select t1.client&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;qspan.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t&amp;amp;i..&amp;amp;desiredvar. as &amp;amp;desiredvar._Q&amp;amp;&amp;amp;Q&amp;amp;i.._&amp;amp;&amp;amp;Y&amp;amp;i..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* you may need to review period macro variable delimiters */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS1 as t1 /* Initiating before looping to balance comma delimiters - it is obviously not logic for your tables to be indexed 1-24 unless they were created within the macro following the&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; same quarters patterns it seems so you will have to review that once you get the hang of the macro */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=2 %to &amp;amp;qspan.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS&amp;amp;i. as t&amp;amp;i.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.CLIENT=t2.CLIENT /* Initiating before looping to balance AND */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=3 %to &amp;amp;qspan.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.CLIENT = t&amp;amp;i..CLIENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; /* closing SQL query */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit; /* Closing proc sql */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%histo_rating(startY=07, startQ=3, endY=13, endQ=2, desiredvar=CD_COTATION);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is all untested but shouldn't be too far off the appropriate syntax. If you need further help debugging, please provide a small sample of 3 tables each with 2-3 client records through datalines statement or something similar or minimally provide the log error report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to allow for user to enter both EAD and CD_COTATION or want the user to enter RATINGS instead of CD_COTATION, it can be done fairly simply in a similar fashion to that of the preformating new macro variables used&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 16:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77668#M16827</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-09-10T16:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77669#M16828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Vincent, this is exactly what I was looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I would like to ask for help debugging please...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run the macro, I got this error message (I used your exact code):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh I have another question : How do I adapt the name of the FROM tables Ratings ? In my project they are named RATINGSQ3_2007 and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the log I got is ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %histo_rating(startY=07, startQ=3, endY=13, endQ=2, desiredvar=CD_COTATION);&lt;/P&gt;&lt;P&gt;ERROR: Required operator not found in expression: &amp;amp;qspan. &lt;/P&gt;&lt;P&gt;ERROR: The %TO value of the %DO I loop is invalid.&lt;/P&gt;&lt;P&gt;ERROR: The macro HISTO_RATING will stop executing.&lt;/P&gt;&lt;P&gt;86&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;87&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GOPTIONS NOACCESSIBLE;&lt;/P&gt;&lt;P&gt;88&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET _CLIENTTASKLABEL=;&lt;/P&gt;&lt;P&gt;89&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET _CLIENTPROJECTPATH=;&lt;/P&gt;&lt;P&gt;90&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET _CLIENTPROJECTNAME=;&lt;/P&gt;&lt;P&gt;91&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET _SASPROGRAMFILE=;&lt;/P&gt;&lt;P&gt;92&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;93&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;*';*";*/;quit;run;&lt;/P&gt;&lt;P&gt;94&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ODS _ALL_ CLOSE;&lt;/P&gt;&lt;P&gt;95&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUIT; RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 10:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77669#M16828</guid>
      <dc:creator>GuiVtzl</dc:creator>
      <dc:date>2013-09-11T10:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77670#M16829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi GuiVtzl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had an unbalanced set of paranthesis for&lt;/P&gt;&lt;P&gt;%let qspan = %eval(&amp;nbsp; (&amp;amp;endy.-&amp;amp;starty.-1)*4&lt;STRONG&gt;)&lt;/STRONG&gt; + (4-&amp;amp;startQ.+1) + &amp;amp;endq.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simply remove the bolded paranthesis above (or replace the line with)&lt;/P&gt;&lt;P&gt;%let qspan = %eval(&amp;nbsp; (&amp;amp;endy.-&amp;amp;starty.-1)*4 + (4-&amp;amp;startQ.+1) + &amp;amp;endq.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the following you can play with the paranthesis and figure out why it was causing such a big turmoil; the shorter portion was evaluated but the rest would be kept as string thus when &amp;amp;sqpan would be derefed elsewhere, it wouldn't be a valid number for loop boundariers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options symbolgen;&lt;/P&gt;&lt;P&gt;%macro histo_rating(startY=, startQ=, endY=, endQ=, desiredvar=);&lt;/P&gt;&lt;P&gt;%let qspan = %eval(&amp;nbsp; (&amp;amp;endy.-&amp;amp;starty.-1)*4) + (4-&amp;amp;startQ.+1) + &amp;amp;endq.);&lt;/P&gt;&lt;P&gt;%put qspan=&amp;amp;qspan.;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%histo_rating(startY=07, startQ=3, endY=13, endQ=2, desiredvar=CD_COTATION);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ask again if anything else goes wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 11:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77670#M16829</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-09-11T11:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77671#M16830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As to answer how to change the FROM statement according to your tables naming convention of RATINGSQ3_2007 and so on,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The FROM block&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS1 as t1 /* Initiating before looping to balance comma delimiters - it is obviously not logic for your tables to be indexed 1-24 unless they were created within the macro following the&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; same quarters patterns it seems so you will have to review that once you get the hang of the macro */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=2 %to &amp;amp;qspan.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGS&amp;amp;i. as t&amp;amp;i.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should be changed as follow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGSQ&amp;amp;Q1._20&amp;amp;Y1. as t1 /* Initiating before looping to balance comma delimiters - it is obviously not logic for your tables to be indexed 1-24 unless they were created within the macro following the&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; same quarters patterns it seems so you will have to review that once you get the hang of the macro */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=2 %to &amp;amp;qspan.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREDITR.RATINGSQ&amp;amp;&amp;amp;Q&amp;amp;i.._20&amp;amp;&amp;amp;Y&amp;amp;i.. as t&amp;amp;i. /* Note again, since you are bouncing between 2 digit and 4 digit year naming convention, the current macro doesn't support 1900s */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 11:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77671#M16830</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-09-11T11:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77672#M16831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Vincent, it works well !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But since my original RATINGS tables are named RATINGSQ3_2007 RATINGSQ4_2007, how could I adapt the code in the "FROM" part ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[SORRY MY COMPUTER LAGGED SO I DIDN'T SEE YOUR SECOND POST !]&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 11:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77672#M16831</guid>
      <dc:creator>GuiVtzl</dc:creator>
      <dc:date>2013-09-11T11:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77673#M16832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works fine again, but I think there's a little problem elsewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact there's a little problem as regard the quarters numbers. Indeed it goes 1 2 3 0 instead of 1 2 3 4&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 12:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77673#M16832</guid>
      <dc:creator>GuiVtzl</dc:creator>
      <dc:date>2013-09-11T12:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77674#M16833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed, I used modulo 4 to build it and did not adjust -_- I'm sorry about this let me see it's probably a simple case of changing paranthesis ordering so that a +1 is applied after the modulo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's shift the translation around to get 0 1 2 3 from modulo (instead of 1 2 3 0) and then add +1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Q&amp;amp;i. = %sysfunc(putn&lt;STRONG&gt;(%eval(&lt;/STRONG&gt;%sysfunc(mod(&amp;amp;startQ.+&amp;amp;i.&lt;STRONG&gt;-2&lt;/STRONG&gt;, 4))&lt;STRONG&gt;+1)&lt;/STRONG&gt;, z1.));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've bolded the changes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like it should correct the issue...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here's my test setup&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro histo_rating(startY=, startQ=, endY=, endQ=, desiredvar=);&lt;BR /&gt;%let qspan = %eval(&amp;nbsp; (&amp;amp;endy.-&amp;amp;starty.-1)*4 + (4-&amp;amp;startQ.+1) + &amp;amp;endq.);&lt;BR /&gt;%do i=1 %to &amp;amp;qspan.; /*create indexed macro variables to simplify looping */&lt;BR /&gt;%let Q&amp;amp;i. = %sysfunc(putn(%eval(%sysfunc(mod(&amp;amp;startQ.+&amp;amp;i.-2, 4))+1), z1.));&lt;BR /&gt;%let Y&amp;amp;i. = %sysfunc(putn(%eval(&amp;amp;startY.+%sysfunc(floor(((&amp;amp;startQ.+&amp;amp;i.-1)-1)/4))), z2.));&lt;BR /&gt;%end;&lt;BR /&gt;%put Q1=&amp;amp;Q1. Q2=&amp;amp;Q2. Q3=&amp;amp;Q3. Q4=&amp;amp;Q4.;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%histo_rating(startY=07, startQ=3, endY=13, endQ=2, desiredvar=CD_COTATION);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested with %put _user_; at first and the Y&amp;amp;i variables looked properly built so we should almost be done with logic debugging&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 12:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77674#M16833</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-09-11T12:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77675#M16834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Vincent,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to say it ? Many many thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You just saved my life at work (I am a complete beginner with SAS and my boss gave me bad "manual" code to automatised).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again, I carefully wrote down your code and I'm going to analyse it to get better with SAS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 12:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77675#M16834</guid>
      <dc:creator>GuiVtzl</dc:creator>
      <dc:date>2013-09-11T12:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform that into a macro (where one can choose what he want to see) ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77676#M16835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yw, I actually enjoy tinkering around macros so it was not work for me anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you ever need further help to understand how/what happens through the macro, feel free to come back to this thread and ask for further explanation. It might not be as almost real time as it was this morning since I don't work for SAS but I typically check communities as my morning routine unless I have urgent project deadlines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 12:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transform-that-into-a-macro-where-one-can-choose-what-he/m-p/77676#M16835</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-09-11T12:20:27Z</dc:date>
    </item>
  </channel>
</rss>

