Re: SASware ballot #18 Proc Transpose preserving variable

  • Follow


What you are asking for is not just variable attributes but a
fundamental change in the way PROC TRANSPOSE works with more than one
variable in the VAR statement.  As long as it doesn't break any
exisiting features.

You can achieve a similar result with PROC SUMMARY but it requires
knowledge of the dimension of the enumerated variable lists being
created.

Data testing;
   Input Group N C $ D mmddyy10.;
   format d mmddyy10.;
   label N='Numeric var'
         C='Text'
         D='Birthday';
   Datalines;
1 57 A 01/15/2010
1 84 B 02/15/2010
2 33 B 03/15/2010
;

/*Proc transpose data=testing out=trans OUTOUT;
   By group;
   Var N D;
   Run;*/
proc summary data=testing nway;
   class group;
   output out=trans(drop=_:) idgroup(out[2](n c d)=);
   run;
proc contents data=trans order=varnum;
Proc print data=trans;
   run;




On 1/21/10, Ted Clay <tclay@ashlandhome.net> wrote:
> SASware ballot #18 refers to Proc Transpose preserving variable attributes.
>
> I'm familiar with the problem and frequently use a macro to solve it, but
> would be delighted to see this feature migrate into Base SAS.
>
>
>
> I am soliciting input from SAS-L in the hopes that this change will be
> implemented in the most useful way.
>
> Posting your comments may have some influence on a future enhancement of
> Proc Transpose.
>
>
>
> First off, I think this requires limiting the output to one observation per
> BY-group.  I can't see any way around that.
>
>
>
> Assuming that is true, one idea for implementing the change to Proc
> Transpose would be to add a "ONEOUT" option on the proc statement.
>
>
>
> Example:
>
> Data testing;
>
>  Input Group N C $ D mmddyy10.;
>
>  format d mmddyy10.;
>
>  label N='Numeric var'
>
>       C='Text'
>
>       D='Birthday';
>
> Datalines;
>
> 1 57 A 01/15/2010
>
> 1 84 B 02/15/2010
>
> 2 33 B 03/15/2010
>
> ;
>
> Proc transpose data=testing out=trans OUTOUT;
>
>  By group;
>
>  Var N D;
>
> Run;
>
>
>
> Proc print data=trans;
>
> Would produce:
>
> Obs    Group    N1            D1    N2            D2
>
>
>
>  1       1      57    01/15/2010    84    02/15/2010
>
>  2       2      33    03/15/2010
>
>
>
> With the ID statement:
>
> Proc transpose data=testing out=trans OUTOUT;
>
>  By group;
>
>  Var N D;
>
>  ID C;
>
> Run;
>
>
>
> Would produce:
>
> Obs    Group    NA            DA    NB            DB
>
>
>
>  1       1      57    01/15/2010    84    02/15/2010
>
>  2       2                          33    03/15/2010
>
>
>
> Other possible options come up in naming the output variables: (1) ID values
> before names (2) a separator between ID values and names, and (3) whether
> and how to modify labels.
>
0
Reply iebupdte (1746) 1/21/2010 4:46:50 PM


0 Replies
57 Views

(page loaded in 0.023 seconds)


Reply: