- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
My observations have FOUR variables: ID, DATE, year1 and year2. I want to create times series(frequency: yearly) data between year1 and year2.
I have already use proc transpose to create a variable YEAR which has year1 and year2 for each observation.
for example for observation A, if year1=1995 and year2=2006, then after the proc transpose I will have two observations A1 with YEAR=1995 and A2 with YEAR=2006.
Then I want to create all the time series observations with YEAR between 1995 and 2006. Namely, Year=1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005.
I tried to use proc expand to solve the problem(I did so with monthly data), but the code below does not work:#
proc expand data=mysample out=mysample1 From=year to=year;
by ID Date;
id YEAR;
convert YEAR;
run;
The code does not work. Is it because I should not use Proc expand or is there something wrong with the code? Or could anyone tell how to solve the problem?
Many thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This should be pretty close to what you need:
data mysample1;
set mysample;
do year = year1 to year2;
output;
end;
drop year1 year2;
run;
If that's not it, perhaps you could explain a little more about what you are looking for.
Good luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Xishuai,
Not sure if I understand right the structure of your data.
Can you provide an example of what your data looks like and the format that you need it?
Thanks,
Miguel
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ah astounding you beat me right to it!
I also think what you are asking for is exactly accomplished by Astounding... I actually came to the exact same solution, a little late tho.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This should be pretty close to what you need:
data mysample1;
set mysample;
do year = year1 to year2;
output;
end;
drop year1 year2;
run;
If that's not it, perhaps you could explain a little more about what you are looking for.
Good luck.