<?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: Creating rows and derived variables in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434665#M107890</link>
    <description>&lt;P&gt;Excellent question! I'm doubling the number of observations and creating a mean derived data point between each of the existing observations. The process is then repeated four times (i.e. 12 observations becomes 192 observations).&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2018 19:11:00 GMT</pubDate>
    <dc:creator>martnic</dc:creator>
    <dc:date>2018-02-06T19:11:00Z</dc:date>
    <item>
      <title>Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434658#M107886</link>
      <description>&lt;P&gt;Hi&amp;nbsp; I'm trying to ''Stretch'' a set of data in SAS and was looking for the most straight forward method...its easy enough in excel but I'm looking to automate a manual process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;obs&amp;nbsp;&amp;nbsp; column1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 01&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp; 02&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P&gt;&amp;nbsp; 03&amp;nbsp;&amp;nbsp; 15&lt;/P&gt;&lt;P&gt;&amp;nbsp; 04&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;obs&amp;nbsp;&amp;nbsp; column1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 01&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp; 02&amp;nbsp; 7.5 (new derived observation)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 03&amp;nbsp; 10 (formerly obs '02')&lt;/P&gt;&lt;P&gt;&amp;nbsp; 04&amp;nbsp; 12.5&amp;nbsp;(new derived observation)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 05&amp;nbsp; 15 (formerly obs '03')&lt;/P&gt;&lt;P&gt;&amp;nbsp; 06&amp;nbsp; 17.5&amp;nbsp;(new derived observation)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 07&amp;nbsp; 20 (formerly obs '05')&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434658#M107886</guid>
      <dc:creator>martnic</dc:creator>
      <dc:date>2018-02-06T19:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434660#M107888</link>
      <description>&lt;P&gt;And what are the rules? You're doubling the observations? Or are you trying to add in missing data points of a series?&lt;/P&gt;
&lt;P&gt;To automate a process, the process first needs to be documented and then it can be automated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191788"&gt;@martnic&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp; I'm trying to ''Stretch'' a set of data in SAS and was looking for the most straight forward method...its easy enough in excel but I'm looking to automate a manual process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp;&amp;nbsp; column1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 01&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 02&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 03&amp;nbsp;&amp;nbsp; 15&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 04&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp;&amp;nbsp; column1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 01&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 02&amp;nbsp; 7.5 (new derived observation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 03&amp;nbsp; 10 (formerly obs '02')&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 04&amp;nbsp; 12.5&amp;nbsp;(new derived observation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 05&amp;nbsp; 15 (formerly obs '03')&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 06&amp;nbsp; 17.5&amp;nbsp;(new derived observation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 07&amp;nbsp; 20 (formerly obs '05')&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434660#M107888</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-06T19:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434665#M107890</link>
      <description>&lt;P&gt;Excellent question! I'm doubling the number of observations and creating a mean derived data point between each of the existing observations. The process is then repeated four times (i.e. 12 observations becomes 192 observations).&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434665#M107890</guid>
      <dc:creator>martnic</dc:creator>
      <dc:date>2018-02-06T19:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434666#M107891</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input obs   column1;
datalines;
  01   5
  02   10
  03   15
  04   20
;

data want;
set have end=last;
output;
if not last then do;
column1=column1+2.5;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434666#M107891</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-06T19:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434672#M107895</link>
      <description>&lt;P&gt;My observation count is different than yours.&amp;nbsp; If you start with 12 observations, you could end up with either 22 or 23 after one iteration.&amp;nbsp; It depends on whether you want to add an observation after the 12th observation.&amp;nbsp; So if you tell us that much, the programming can begin.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434672#M107895</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-06T19:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434679#M107901</link>
      <description>&lt;P&gt;Sorry for the poor communication\detail, its my first time using these boards...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my excel tables I go from 12 observations to 24, from 24 to 48, from 48 to 96, and from 96 to 192. (12^4=192).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in my first iteration obs 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 become obs 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, and 23 with obs 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, and 24 being derived as the mean between the two starting obs. (i.e. obs2 = average(obs1,obs3), obs4 = average(obs3, obs5)...obs24 = average(obs23, obs25*)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*obs25 is a blank row with a value of 0&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434679#M107901</guid>
      <dc:creator>martnic</dc:creator>
      <dc:date>2018-02-06T19:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434680#M107902</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input obs   column1;
datalines;
  01   5
  02   10
  03   15
  04   20
;

data want;
set have end=last;
_k=lag(column1);
if _n_&amp;gt;1 then do;
_col=column1;
column1=mean(_k,column1);
output;
column1=_col;
output;
end;
else output;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434680#M107902</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-06T19:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating rows and derived variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434683#M107903</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; Plus:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if last then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; column1 = column1/2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then a new step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set want (drop=obs);&lt;/P&gt;
&lt;P&gt;obs = put(_n_, z3.);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 20:24:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-rows-and-derived-variables-in-SAS/m-p/434683#M107903</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-06T20:24:24Z</dc:date>
    </item>
  </channel>
</rss>

