<?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: Adding Observations by Year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236659#M43370</link>
    <description>&lt;P&gt;What should happen if a firm has multiple entries in your source dataset?&lt;/P&gt;
&lt;P&gt;Can you please show us your desired result for&amp;nbsp;_cik=0001046649&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/949iE3589CADD488EFE6/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not my area of expertise but should you intend to create such data as preparation for time series then look into Proc Expand.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Nov 2015 20:09:26 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-11-26T20:09:26Z</dc:date>
    <item>
      <title>Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236625#M43349</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I currently have a dataset with 1 observation per firm in various years.&amp;nbsp; For example, I have a firm with a 1998 observation.&amp;nbsp; Is there a way to code it where I can get lines for 1995, 1996, 1997, 1999, 2000, and 2001 observations for the same firm (3 years before and 3 years after)?&amp;nbsp; That way, instead of having 1 observation per firm, I will have 7.&amp;nbsp; Finally, I would like to delete the original observation (1998 in my example).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks so much!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jadallah&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236625#M43349</guid>
      <dc:creator>jjadall1</dc:creator>
      <dc:date>2015-11-26T16:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236627#M43351</link>
      <description>If you give an example data it will help</description>
      <pubDate>Thu, 26 Nov 2015 16:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236627#M43351</guid>
      <dc:creator>pearsoninst</dc:creator>
      <dc:date>2015-11-26T16:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236629#M43353</link>
      <description>&lt;P&gt;The dataset I'm working with is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much!&lt;/P&gt;
&lt;P&gt;Jadallah&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236629#M43353</guid>
      <dc:creator>jjadall1</dc:creator>
      <dc:date>2015-11-26T17:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236653#M43366</link>
      <description>&lt;PRE&gt;This code is working , but i think you get better soluation in this forum . &lt;BR /&gt;&lt;BR /&gt;data newdata;
Input Id$ Year;
datalines;
A 1998
;
run;
Data want1;
set newdata;
Do i = 1 to 3;
  Year1 = Year+(i);
Output;
End;
drop i year;
run;
Data want2;
set newdata;
Do i = 1 to 3;
  Year2 = Year-(i);
Output;
End;
drop i year;
run;
Proc SQL;
Select* 
   from want1
   union All
Select*
   from want2;
quit;
 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 19:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236653#M43366</guid>
      <dc:creator>pearsoninst</dc:creator>
      <dc:date>2015-11-26T19:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236656#M43368</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/59783"&gt;@pearsoninst﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;An simpler coding variant for what you're proposing is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Id$ Year;
  datalines;
A 1998
;
run;
data want(drop=_y);
  set have(rename=(year=_y));
  do year= _y-3 to _y-1 , _y+1 to _y+3 ;
    output;
  end;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 19:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236656#M43368</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-26T19:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236657#M43369</link>
      <description>Cool one Patrick, I was little lost with the below code &lt;BR /&gt; do year= _y-3 to _y-1 , _y+1 to _y+3 ;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Nov 2015 19:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236657#M43369</guid>
      <dc:creator>pearsoninst</dc:creator>
      <dc:date>2015-11-26T19:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236659#M43370</link>
      <description>&lt;P&gt;What should happen if a firm has multiple entries in your source dataset?&lt;/P&gt;
&lt;P&gt;Can you please show us your desired result for&amp;nbsp;_cik=0001046649&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/949iE3589CADD488EFE6/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not my area of expertise but should you intend to create such data as preparation for time series then look into Proc Expand.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 20:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236659#M43370</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-26T20:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236666#M43375</link>
      <description>&lt;P&gt;The do loop allows for quite a few different variations of syntax.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a look at Example1:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p1cydk5fq0u4bfn1xfbjt7w1c7lu.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p1cydk5fq0u4bfn1xfbjt7w1c7lu.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 21:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236666#M43375</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-26T21:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Observations by Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236722#M43387</link>
      <description>&lt;P&gt;Thanks for the help - God bless you and your family! &amp;nbsp;The reason there are multiple entries of the same firm is because I have a treatment group and a control group; with the control group, I did matching with replacement. &amp;nbsp;It would be great to know how to do matching without replacement for the future.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 11:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Observations-by-Year/m-p/236722#M43387</guid>
      <dc:creator>jjadall1</dc:creator>
      <dc:date>2015-11-27T11:26:43Z</dc:date>
    </item>
  </channel>
</rss>

