Date: Wed, 13 Feb 2008 16:50:02 -0500
Reply-To: "data _null_," <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_," <datanull@GMAIL.COM>
Subject: Re: Please help with my coding problem!
In-Reply-To: <7367b4e20802131341v3c8116e9n7ae6e4154a18baff@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Now that you have a solution, I need to ask why. I have on occasion
has to do similar, decode a variable into itself but this is a rare
event for me. Usually working with coded values and using the value
labels for display or grouping is sufficient no need to change the
values to the value labels.
On Feb 13, 2008 4:41 PM, data _null_, <datanull@gmail.com> wrote:
> With 100 variables you need something more dynamic that the solutions
> proposed. This can be accomplished many way but using
> DICTIONARY.COLUMNS is a pretty easy way.
>
> %let varlist=;
> proc sql;
> select name into :varlist separated by ' '
> from dictionary.columns
> where libname eq 'WORK' and memname eq 'TEST' and type eqt 'c';
> quit;
> run;
> %put NOTE: Varlist=&varlist;
> data try (drop=i);
> length &varlist $20;
> set test;
> array a(*) _character_;
> do i = 1 to dim(a);
> a[i]=put(a[i], $name.);
> end;
> run;
>
> On Feb 13, 2008 4:21 PM, Xuhong <zhuxuhong2000@gmail.com> wrote:
>
> > Dear folks,
> >
> > Please help me resolve the coding problems as showed below.
> > (I simplify my coding problems into a example as showed below. The
> > problem here is the final results only show the default 8 digits. I
> > also couldn't use "input" since the dataset I am using is already in
> > SAS format and the dataset has more than 100 character variables and
> > thousands of observations.
> > So, please help me to resolve the variable length problem at the array
> > part! Thanks very much!
> >
> > proc format;
> > value $name
> > "A"="assistant professor"
> > "B"="associate professor"
> > "C"="stuff";
> > run;
> >
> > data test;
> > input first $ second $ third $;
> > datalines;
> > A B C
> > B B A
> > C A B
> > ;
> >
> > data try (drop=i);
> > set test;
> > array a(*) _character_;
> > do i = 1 to dim(a);
> > a[i]=put(a[i], $name.);
> > end;
> > run;
> >
>
|