<?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: DO loop Query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337347#M76594</link>
    <description>&lt;P&gt;This is how you get the values for one month:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by peril year_month;
run;

%let comp_month=201501;

data want;
merge
  have
  have (
    rename=(bc=bc_comp year_month=ym)
    where=(ym = "&amp;amp;comp_month")
  )
;
by peril;
comp_&amp;amp;comp_month = bc / bc_comp;
drop ym bc_comp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How you expand that for a multitude of months depends on what you want to do with the data later on.&lt;/P&gt;
&lt;P&gt;Usually it is not a good idea to have data (year/month) in structure (variable names).&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2017 13:58:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-03-02T13:58:14Z</dc:date>
    <item>
      <title>DO loop Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337336#M76590</link>
      <description>&lt;P&gt;I have a dataset in the below format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year_month &amp;nbsp; Peril &amp;nbsp; &amp;nbsp;Average BC&lt;/P&gt;&lt;P&gt;201501 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BI &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;130&lt;/P&gt;&lt;P&gt;201502 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PD &amp;nbsp; &amp;nbsp; &amp;nbsp; 150&amp;nbsp;&lt;/P&gt;&lt;P&gt;201503 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 170&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a report such that when i plot this months in excel on X axis, i get an option to set one month as base and rest figures should be divided by that base figure. I want an option to change the base month like first it should 201501, then 201502 , I have attached a sample data to make it more clear. request yoy to provide the reponse asap.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 13:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337336#M76590</guid>
      <dc:creator>RamandeepSingh</dc:creator>
      <dc:date>2017-03-02T13:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337347#M76594</link>
      <description>&lt;P&gt;This is how you get the values for one month:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by peril year_month;
run;

%let comp_month=201501;

data want;
merge
  have
  have (
    rename=(bc=bc_comp year_month=ym)
    where=(ym = "&amp;amp;comp_month")
  )
;
by peril;
comp_&amp;amp;comp_month = bc / bc_comp;
drop ym bc_comp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How you expand that for a multitude of months depends on what you want to do with the data later on.&lt;/P&gt;
&lt;P&gt;Usually it is not a good idea to have data (year/month) in structure (variable names).&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 13:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337347#M76594</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-02T13:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337349#M76596</link>
      <description>&lt;P&gt;I devised an SQL approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let selectym=201501;
proc sql;
	create table want as
		select h1.yearmonth, h1.peril, h1.bc, h2.bc as bc2, h1.bc/h2.bc as bc_ratio
		from have h1, (select yearmonth, peril, bc from have  h3 where h3.yearmonth=&amp;amp;selectym) h2
		where h1.peril=h2.peril and h2.yearmonth=&amp;amp;selectym;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 14:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-Query/m-p/337349#M76596</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-02T14:03:56Z</dc:date>
    </item>
  </channel>
</rss>

