<?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 Generate a sequence of observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71005#M20485</link>
    <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset with 5 observations;&lt;BR /&gt;
&lt;BR /&gt;
OBSERVATION&lt;BR /&gt;
&lt;BR /&gt;
F&lt;BR /&gt;
T&lt;BR /&gt;
J&lt;BR /&gt;
D&lt;BR /&gt;
D&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I want to spread the observations like this (so the first obervation has to be there for the first five days, the second observations has to be there for the next five days, (from day 6 to 10,... and so on);&lt;BR /&gt;
&lt;BR /&gt;
I want to come up with the following dataset;&lt;BR /&gt;
&lt;BR /&gt;
DAY,OBSERVATION&lt;BR /&gt;
1,F&lt;BR /&gt;
2,F&lt;BR /&gt;
3,F&lt;BR /&gt;
4,F&lt;BR /&gt;
5,F&lt;BR /&gt;
6,T&lt;BR /&gt;
7,T&lt;BR /&gt;
8,T&lt;BR /&gt;
9,T&lt;BR /&gt;
10,T&lt;BR /&gt;
11,J&lt;BR /&gt;
12,J&lt;BR /&gt;
13,J&lt;BR /&gt;
14,J&lt;BR /&gt;
15,J&lt;BR /&gt;
16,D&lt;BR /&gt;
17,D&lt;BR /&gt;
18,D&lt;BR /&gt;
19,D&lt;BR /&gt;
20,D&lt;BR /&gt;
21,D&lt;BR /&gt;
22,D&lt;BR /&gt;
23,D&lt;BR /&gt;
24,D&lt;BR /&gt;
25,D&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I have programmed this in the following way,&lt;BR /&gt;
&lt;BR /&gt;
options nomprint nosymbolgen nomlogic;&lt;BR /&gt;
%macro result;&lt;BR /&gt;
&lt;BR /&gt;
data  %do i=1 %to 5;&lt;BR /&gt;
&lt;BR /&gt;
Data VECTOR_PRE (drop=obsnum);&lt;BR /&gt;
obsnum=&amp;amp;i;&lt;BR /&gt;
set VECTOR_ point=obsnum;&lt;BR /&gt;
output;&lt;BR /&gt;
stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
DATA OUTPUT&amp;amp;i;&lt;BR /&gt;
SET VECTOR_PRE;&lt;BR /&gt;
day=0;&lt;BR /&gt;
do day=&amp;amp;i*(30)-30+1 to &amp;amp;i*(30);&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
	    %end;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data sasuser.want; &lt;BR /&gt;
set output: indsname=dsn; &lt;BR /&gt;
drop dsn;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend ; &lt;BR /&gt;
%result&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to do this in a datastep, so without using a macro?&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
&lt;BR /&gt;
Stefaan

Message was edited by: OzoneX15</description>
    <pubDate>Mon, 30 May 2011 05:38:57 GMT</pubDate>
    <dc:creator>OzoneX15</dc:creator>
    <dc:date>2011-05-30T05:38:57Z</dc:date>
    <item>
      <title>Generate a sequence of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71005#M20485</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset with 5 observations;&lt;BR /&gt;
&lt;BR /&gt;
OBSERVATION&lt;BR /&gt;
&lt;BR /&gt;
F&lt;BR /&gt;
T&lt;BR /&gt;
J&lt;BR /&gt;
D&lt;BR /&gt;
D&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I want to spread the observations like this (so the first obervation has to be there for the first five days, the second observations has to be there for the next five days, (from day 6 to 10,... and so on);&lt;BR /&gt;
&lt;BR /&gt;
I want to come up with the following dataset;&lt;BR /&gt;
&lt;BR /&gt;
DAY,OBSERVATION&lt;BR /&gt;
1,F&lt;BR /&gt;
2,F&lt;BR /&gt;
3,F&lt;BR /&gt;
4,F&lt;BR /&gt;
5,F&lt;BR /&gt;
6,T&lt;BR /&gt;
7,T&lt;BR /&gt;
8,T&lt;BR /&gt;
9,T&lt;BR /&gt;
10,T&lt;BR /&gt;
11,J&lt;BR /&gt;
12,J&lt;BR /&gt;
13,J&lt;BR /&gt;
14,J&lt;BR /&gt;
15,J&lt;BR /&gt;
16,D&lt;BR /&gt;
17,D&lt;BR /&gt;
18,D&lt;BR /&gt;
19,D&lt;BR /&gt;
20,D&lt;BR /&gt;
21,D&lt;BR /&gt;
22,D&lt;BR /&gt;
23,D&lt;BR /&gt;
24,D&lt;BR /&gt;
25,D&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I have programmed this in the following way,&lt;BR /&gt;
&lt;BR /&gt;
options nomprint nosymbolgen nomlogic;&lt;BR /&gt;
%macro result;&lt;BR /&gt;
&lt;BR /&gt;
data  %do i=1 %to 5;&lt;BR /&gt;
&lt;BR /&gt;
Data VECTOR_PRE (drop=obsnum);&lt;BR /&gt;
obsnum=&amp;amp;i;&lt;BR /&gt;
set VECTOR_ point=obsnum;&lt;BR /&gt;
output;&lt;BR /&gt;
stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
DATA OUTPUT&amp;amp;i;&lt;BR /&gt;
SET VECTOR_PRE;&lt;BR /&gt;
day=0;&lt;BR /&gt;
do day=&amp;amp;i*(30)-30+1 to &amp;amp;i*(30);&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
	    %end;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data sasuser.want; &lt;BR /&gt;
set output: indsname=dsn; &lt;BR /&gt;
drop dsn;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend ; &lt;BR /&gt;
%result&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to do this in a datastep, so without using a macro?&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
&lt;BR /&gt;
Stefaan

Message was edited by: OzoneX15</description>
      <pubDate>Mon, 30 May 2011 05:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71005#M20485</guid>
      <dc:creator>OzoneX15</dc:creator>
      <dc:date>2011-05-30T05:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Generate a sequence of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71006#M20486</link>
      <description>Hi:&lt;BR /&gt;
  It may be that a macro solution is too much programming for what you need.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data genobs;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  drop i;&lt;BR /&gt;
  retain day 0;&lt;BR /&gt;
  input @1 obsval $;&lt;BR /&gt;
  do i = 1 to 5 by 1;&lt;BR /&gt;
    day + 1;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
datalines;&lt;BR /&gt;
F&lt;BR /&gt;
T&lt;BR /&gt;
J&lt;BR /&gt;
D&lt;BR /&gt;
D&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
proc print data=genobs noobs;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 30 May 2011 06:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71006#M20486</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-05-30T06:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Generate a sequence of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71007#M20487</link>
      <description>Hi.Sorry so late to reponse.&lt;BR /&gt;
How about this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input obs $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
F&lt;BR /&gt;
T&lt;BR /&gt;
J&lt;BR /&gt;
D&lt;BR /&gt;
D&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want(drop=i);&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 do i=1 to 5;&lt;BR /&gt;
 day+1; output;&lt;BR /&gt;
 end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
My code I send you this morning is worked?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 30 May 2011 11:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71007#M20487</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-30T11:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Generate a sequence of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71008#M20488</link>
      <description>Thanks Cynthia and Ksharp.&lt;BR /&gt;
&lt;BR /&gt;
@ Ksharp: Yes the code works perfectly. I've learned to work with arrays now...&lt;BR /&gt;
but still need to practice:-)&lt;BR /&gt;
&lt;BR /&gt;
Stefaan</description>
      <pubDate>Mon, 30 May 2011 17:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-a-sequence-of-observations/m-p/71008#M20488</guid>
      <dc:creator>OzoneX15</dc:creator>
      <dc:date>2011-05-30T17:55:00Z</dc:date>
    </item>
  </channel>
</rss>

