<?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: Paneling Data by Month/Year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263255#M269192</link>
    <description>&lt;P&gt;Thanks! Last (hopefully!) wrinkle. I now have a missing month when it skips to following month for the 15th or later dates. So it will go from Jan to Mar (skip Feb). I would want the data to carry from Jan to Feb. Suggestions?&lt;/P&gt;</description>
    <pubDate>Tue, 12 Apr 2016 16:23:39 GMT</pubDate>
    <dc:creator>sklieger</dc:creator>
    <dc:date>2016-04-12T16:23:39Z</dc:date>
    <item>
      <title>Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263188#M269173</link>
      <description>&lt;P&gt;Good morning!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create panel data from a legal dataset that has rows of data by state with a start date and an end date reflecting when laws were enacted/changed. I've been able to panel the data by year, but I need it to be by month &amp;amp; year such that every month between start and end date is included as a row. Many rows will have identical data as the laws don't change frequently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem I'm having is that a state might have the same law from 1/1/1980 until 2/1/2010 and when I try to panel it by month, I'm only getting Jan and Feb, rather than Jan-Dec for all years until 2010 (when it should just be Jan-Feb). Here's the code I used to panel by year, which worked:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Extract Year, Month, Day from Begin Date &amp;amp; End Date;
data date;
set eitc;
Start_Year = year(Begin_Date);
End_Year = year(End_Date);
Start_month = month(begin_date);
end_month = month(end_date);
Start_Day = day(Begin_date);
End_day = day(end_date);
if start_day&amp;gt;14 then new_month=start_month+1;
else new_month=start_month;
run;
&amp;nbsp;
*Sort by State Year Month;
proc sort data=date;
by state start_year new_month;
run;
&amp;nbsp;
*Panel Data by year;
data year;
set date;
by state;
do year = start_year to end_year;
output;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would really appreciate any suggestions! Please let me know if more information would be helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sarah&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263188#M269173</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T14:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263199#M269174</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be useful to show some test data in the form of a datastep and what you want the output to look like. &amp;nbsp;I am not familiar with "panel by"? &amp;nbsp;It looks like you need to loop over an interval:&lt;/P&gt;
&lt;P&gt;do i=1 to intck('month',month,start_date,end date);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; date=intnx('month',start_date,i-1);&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263199#M269174</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T14:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263203#M269175</link>
      <description>&lt;P&gt;Create a new variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;yearmon = start_year * 100 + new_month;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and sort by that.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263203#M269175</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-12T14:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263204#M269176</link>
      <description>&lt;P&gt;Thanks for the quick reply! I'm not sure what you mean by showing test data in a datastep. Does&amp;nbsp;the attached help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263204#M269176</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T14:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263206#M269177</link>
      <description>Hi Kurt,&lt;BR /&gt;&lt;BR /&gt;Thanks for your response. I tried that approach and also just ran your code and am getting the same result: it's showing me the months for which changes to data were reflected in changes to the start_date, but it's not creating rows for every month and carrying the data down until the next change.</description>
      <pubDate>Tue, 12 Apr 2016 14:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263206#M269177</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T14:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263207#M269178</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80825"&gt;@sklieger﻿&lt;/a&gt;&amp;nbsp;I edited your post to format code - not really required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I understand correctly this is common question. Do you have SAS/ETS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, can you post data in the forum directly rather than as an Excel file, not everyone downloads files.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263207#M269178</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-12T14:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263212#M269179</link>
      <description>&lt;P&gt;Not really, I am afraid I can't download Excel files as they are a secutiry risk. &amp;nbsp;However I extrapolated the first record from it and sho an example here:&lt;/P&gt;
&lt;PRE&gt;data have (drop=i);
  state="AZ"; begin_date="01JAN1980"d; end_date="02Jan2016"d;
  do i=1 to intck('month',begin_date,end_date);
    mon_yr=cats(put(month(intnx('month',begin_date,i-1)),z2.),"-",put(year(intnx('month',begin_date,i-1)),z4.));
    output; 
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263212#M269179</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T14:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263213#M269180</link>
      <description>I think so?&lt;BR /&gt;271 PROC PRODUCT_STATUS;RUN;&lt;BR /&gt;&lt;BR /&gt;For Base SAS Software ...&lt;BR /&gt;Custom version information: 9.4_M2&lt;BR /&gt;Image version information: 9.04.01M2P072314&lt;BR /&gt;For SAS/STAT ...&lt;BR /&gt;Custom version information: 13.2&lt;BR /&gt;For SAS/GRAPH ...&lt;BR /&gt;Custom version information: 9.4_M2&lt;BR /&gt;For SAS/ETS ...&lt;BR /&gt;Custom version information: 13.2&lt;BR /&gt;&lt;BR /&gt;I tried to post data to the forum and it wasn't formatting correctly. I'll try again.</description>
      <pubDate>Tue, 12 Apr 2016 14:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263213#M269180</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T14:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263216#M269182</link>
      <description>&lt;P&gt;HAVE (State, Start_Date, End_Date)&lt;/P&gt;&lt;P&gt;AK, 1/1/1980, 2/1/2016,&lt;/P&gt;&lt;P&gt;AR, 1/1/1988, 12/31/1990,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WANT (State, Start_Date, End_Date, Mo_yearvar)&lt;/P&gt;&lt;P&gt;AK, 1/1/1980, 2/1/2016, 1/1980&lt;/P&gt;&lt;P&gt;AK, 1/1/1980, 2/1/2016, 2/1980&lt;/P&gt;&lt;P&gt;AK, 1/1/1980, 2/1/2016, 3/1980&lt;/P&gt;&lt;P&gt;AK, 1/1/1980, 2/1/2016, 4/1980&lt;/P&gt;&lt;P&gt;AK, 1/1/1980, 2/1/2016, 5/1980&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;AR, 1/1/1988, 12/31/1990, 1/1/1988&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AR, 1/1/1988, 12/31/1990, 2/1/1988&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;AR, 1/1/1988, 12/31/1990, 3/1/1988&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AR, 1/1/1988, 12/31/1990, 4/1/1988&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263216#M269182</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T14:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263219#M269183</link>
      <description>&lt;P&gt;Great, that worked for AZ! I have a dataset with all 50 states. Do I need to repeat the step for each state?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263219#M269183</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T14:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263228#M269184</link>
      <description>&lt;P&gt;The do loop will run for each observation in your dataset, so it will do the loop for _n_=1, then for _n_=2 to _n_=last, and expand each date.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 15:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263228#M269184</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T15:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263231#M269185</link>
      <description>For some reason, it's only doing it for AZ. Do I need to add code?</description>
      <pubDate>Tue, 12 Apr 2016 15:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263231#M269185</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T15:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263232#M269186</link>
      <description>&lt;P&gt;I cannot tell without seeing the code you are running and the data you are running over. &amp;nbsp;I am assuming that your replace the below in your code with a set for the data you have?&lt;/P&gt;
&lt;PRE&gt;data have (drop=i);
  state="AZ"; begin_date="01JAN1980"d; end_date="02Jan2016"d;    &amp;lt;- replace this with set &amp;lt;your_dataset&amp;gt;;!!
  do i=1 to intck('month',begin_date,end_date);
    mon_yr=cats(put(month(intnx('month',begin_date,i-1&lt;WBR /&gt;)),z2.),"-",put(year(intnx('month',begin_date,i-1)&lt;WBR /&gt;),z4.));
    output; 
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 15:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263232#M269186</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T15:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263233#M269187</link>
      <description>&lt;P&gt;Here's my code, with yours at the bottom:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname eitc 'C:\Users\tub68397\Desktop\Projects\Legal Datasets\Panel Datasets for Nick';

*Import Excel Data;
PROC IMPORT OUT= work.eitc DATAFILE= "C:\Users\tub68397\Desktop\Projects\Legal Datasets\Panel Datasets for Nick\2_1_2016 EITC Data Stat.xlsx" 
            DBMS=xlsx REPLACE;
     SHEET="2_1_2016 EITC Data"; 
     GETNAMES=YES;
RUN;

proc print data=eitc;
run;

*Extract Year, Month, Day from Begin Date &amp;amp; End Date;
data date;
set eitc;
Start_Year = year(Begin_Date);
End_Year = year(End_Date);
Start_month = month(begin_date);
end_month = month(end_date);
Start_Day = day(Begin_date);
End_day = day(end_date);
if start_day&amp;gt;14 then new_month=start_month+1;
else new_month=start_month;
yearmon = start_year * 100 + new_month;
format yearmon mmyys.;
run;

*Sort by State Year Month;
proc sort data=date;
by state start_year new_month;
run;

*Panel Data by year;
data year;
set date;
by state;
do year = start_year to end_year;
output;
end;
run;


data have (drop=i);
set year;
  state="AK"; begin_date="01JAN1980"d; end_date="02Jan2016"d;
  do i=1 to intck('month',begin_date,end_date);
    mon_yr=cats(put(month(intnx('month',begin_date,i-1)),z2.),"-",put(year(intnx('month',begin_date,i-1)),z4.));
    output; 
  end;
run;

proc freq data=have;
tables state;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 15:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263233#M269187</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T15:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263234#M269188</link>
      <description>&lt;P&gt;Yes, remove this line, I put that in as example data, you don't want that to be used in your data!&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  state&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"AK"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; begin_date&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"01JAN1980"&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; end_date&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"02Jan2016"&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;;   &amp;lt;--- drop&lt;/SPAN&gt;
  do i&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;begin_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;end_date&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    mon_yr&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intnx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;begin_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;z2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"-"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intnx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;begin_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;z4&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oh, and whilst your looking at it, make sure your variables match the data you have. &amp;nbsp;This is why we ask for test data - in the form of a datastep, so that we program on the same data you are programming on.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 15:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263234#M269188</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T15:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263238#M269189</link>
      <description>Okay, data look good now. I generally import data form Excel. How would I show data in the form of a data step?&lt;BR /&gt;&lt;BR /&gt;One other, related question, if I want to use a rule to assign month based on day, how would I incorporate that into the code I have? For example, if a law changed during the first 14 days of a month, I want to use the month already there in the Begin_Date. If the law changed on Day 15 or after, I want to change the month to the following month. So April 14, stay April. April 15th, change to May. Can that be done in the do loop?&lt;BR /&gt;&lt;BR /&gt;Thanks for all your help!!</description>
      <pubDate>Tue, 12 Apr 2016 15:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263238#M269189</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T15:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263244#M269190</link>
      <description>&lt;P&gt;For point 1, Reeza has posted a good article on how to post data here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your second point, you can use if statements in the do loop, or anywhere in code.&amp;nbsp; I would suggest you probably want it before the do loop - i.e. to apply to the whole loop&lt;/P&gt;
&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;  if day(begin_date) &amp;gt; 14 then begin_date=intnx('month',begin_date,1);&lt;/SPAN&gt;
  do i&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;begin_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;end_date&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    mon_yr&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cats&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intnx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;begin_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;z2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"-"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intnx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;begin_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;z4&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;This will increment begin_date by 1 month if day &amp;gt; 14, and then loop uses begin_date...&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 16:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263244#M269190</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-12T16:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263248#M269191</link>
      <description>&lt;P&gt;Something like this perhaps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data date;
   set eitc;
   do Effect_Month = mdy(month(begin_date),1,year(begin_date) to mdy(month(end_date),1,year(end_date);
      output;
   end;
   format Effect_month   mmyys7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;adds a variable that is a date varaible with the value of the the first day of each month begin to end Formatted to look like month and year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 16:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263248#M269191</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-12T16:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263255#M269192</link>
      <description>&lt;P&gt;Thanks! Last (hopefully!) wrinkle. I now have a missing month when it skips to following month for the 15th or later dates. So it will go from Jan to Mar (skip Feb). I would want the data to carry from Jan to Feb. Suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 16:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263255#M269192</guid>
      <dc:creator>sklieger</dc:creator>
      <dc:date>2016-04-12T16:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Paneling Data by Month/Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263380#M269193</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data date;
   set eitc;
   do Effect_Month = mdy(month(begin_date),1,year(begin_date) )
                             to mdy(month(end_date),1,year(end_date));

if day(Effect_Month)=1 then   output;

   end;
   format Effect_month   mmyys7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paneling-Data-by-Month-Year/m-p/263380#M269193</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-13T02:31:57Z</dc:date>
    </item>
  </channel>
</rss>

