On 06/01/2012 4:01 PM, Chris wrote:
> Each region has information on several variables. I want to
> copy region1 and make 30 identical lines. Region2 could be duplicate
> 18 times, and so on.
LOOP and XSAVE should do the trick. Something like this:
* Read in sample data.
data list list / region v1 v2 v3 v4 (5f2.0).
begin data
1 2 6 7 9
2 6 8 9 2
3 5 7 4 2
end data.
* Compute a scratch variable holding the desired
* number of rows for each region .
* This example shows how to do it for 3 regions;
* the OP will need to add more recodes for regions
* 4 to 17.
recode region
(1 = 30)
(2 = 18)
(3 = 5)
into #NumRows
.
* Use LOOP and XSAVE to write a file with the desired number
* of rows for each region.
loop copy = 1 to #NumRows.
xsave outfile = "C:\temp\expanded file.sav" / keep = copy all .
end loop.
execute.
get file = "C:\temp\expanded file.sav" .
formats copy (f5.0).
list.
--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."