|
or swap the PROC TRANSPOSE & DATA STEP:
*******************************************;
data have;
array _a[*] a b c d e f g h i (1:9);
do _n_ = 1 to 7;
output;
end;
run;
data out;
set have;
array _a{*} _numeric_;
do j=1 to dim(_a); name=cats(vname(_a[j]), _n_); obs=_a[j];
output; end;
keep name obs;
run;
proc sql;
create view outv as
select * from out order by name;
quit;
proc transpose data=outv out=out2 name=name;
id name;
run;
On Thu, 9 Sep 2010 12:30:43 -0500, Data _null_; <iebupdte@GMAIL.COM> wrote:
>I want to join in too!
>
>This should work for a resonable number of OBS and VARs.
>No counting required.
>
>data have;
> array _a[*] a b c d e f g h i (1:9);
> do _n_ = 1 to 7;
> output;
> end;
> run;
>proc transpose out=id name=id;
>proc transpose out=tall; by id;
>data tall;
> length _name_ $32;
> set tall;
> _name_ = tranwrd(_name_,'COL',trim(ID));
> run;
>proc transpose out=arrayed(drop=_name_);
> run;
>proc print;
> run;
>
>
>
>On 9/9/10, Randall Powers <powers_r@bls.gov> wrote:
>> Hello All.
>>
>> I have this dataset:
>>
>> obs a b c d e f g h i
>> 1
>> 2
>> 3
>> 4
>> 5
>> 6
>> 7
>>
>>
>> Hence, nine variables, seven observations.
>>
>> What I'd like to end up with is a dataset with one observation containing
>> nine arrays with the previous observation number as the array index.
>> Hence,7*9=63 variables:
>>
>> obs a1 a2 a3 a4 a5 a6 a7 b1 b2 b3....b7.....i7
>> 1
>>
>> How do I do this?
>>
>> Thanks!
>>
|