| Date: | Fri, 3 Mar 2006 15:22:07 -0800 |
| Reply-To: | David L Cassell <davidlcassell@MSN.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | David L Cassell <davidlcassell@MSN.COM> |
| Subject: | Re: Proc logistic error |
| In-Reply-To: | <200603032057.k23JaAWc012332@mailgw.cc.uga.edu> |
| Content-Type: | text/plain; format=flowed |
|---|
kviel@EMORY.EDU replied:
> > Actually I need some help with the macro to do that rename. I did a
> > proc contents, saved the file, opened it in UE, used column editing to
> > remove everything but the list of items, pasted them into Excel, and
> > built the rest of my rename statement around it. I intended to do the
> > same to make a label statement.
>
>Well, you don't actually need a macro to do it. I meant the facility.
>
>
>/* UNTESTED */
>data _null_ ;
>
> length ren lab $ 5000 ;
>
> do _n_ = 1 by 1 until ( end ) ;
> set sashelp.vcolumns ( where = ( libname = "" and memname = "" )) end
>= end ;
>
> ren = compbl( ren ) || compress( name ) || " = x" || put( _n_ , z3. )
>;
> lab = compbl( lab ) || " x" || put( _n_ , z3. ) || ' = "' || compress(
>name ) || '"' ;
> end ;
> call symput( "rename" , ren ) ;
> call symput( "label" , lab ) ;
> stop ;
>run ;
>
>data two ;
> set one ( rename = ( &rename. )) ;
> label &label. ;
>run ;
>
>Note that this renames *every* variable in your dataset. You can make and
>exclusion list using the DATASET OPTION above. Second, I am very, very
>forgetful of the SASHELP files. You should verify them yourself.
>
>You could also have used the SQL procedure, but I just put down that code
>because I am not confident about how I would get the equilavent to _n_.
Or, much simpler, just use SAS list naming conventions, If you have 541
variables starting with WALLABY and ending with KINETIC , in that order
in the PDV (as shown if you look using PROC CONTENTS) then you can
access them all just by saying
wallaby--kinetic
Note the two dashes between the variables. So maybe there's no need for
a large renaming process that will make the interpretation that much harder.
HTH,
David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
|