Date: Fri, 1 Sep 2006 08:51:41 -0400
Reply-To: Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Subject: Re: proc informat/ proc format?
Hi Arjen,
While defining a new array you have to define its type too.
You did not define character type, so array ZZ is numeric.
I don't know by head where, but you have to include the $
character somewhere in the array definition of ZZ.
Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
home.hccnet.nl/jim.groeneveld
On Fri, 1 Sep 2006 05:39:30 -0700, Arjen <a.benedictus@GMAIL.COM> wrote:
>Hello SAS-L,
>
>Yesterday I posted a question to which a proc informat-solution proved
>to be a good answer. Today I decided that I will be able to cut a lot
>of code when I do it the other way round, that is, to start with
>numeric values and transform them into character variables later on.
>Hence the question: I want to convert these numerical variables into
>character variables using proc format, but I get an error saying
>"invalid numeric data". Any suggestions? (tested code below)
>
>Thanks!
>
>Arjen
>
>%LET d1 = VirusOne;
>%LET d2 = VirusTwo;
>%LET d3 = VirusThree;
>
>data have;
> input &d1 &d2 &d3 @@;
> cards;
> 1 2 2 2 2 3 2 1 1 3
> 3 1 3 2 2 1 2 1 2 1
> 1 1 2 2 2 3 2 3 2 2
> ;
>run;
>
>proc format ;
> value result
>1= "p"
>2= "n"
>3= "u"
>other = .
>;
>run;
>
>data have2 (DROP=I);
> set have;
> array nn [1:3] &D1 &D2 &D3;
> array zz [1:3] z&D1 z&D2 z&D3;
> do i = 1 to 3;
> zz[i] = put (nn[i], result.);
> end;
>run;
|