Date: Mon, 13 May 2002 09:47:25 -0600
Reply-To: William Kossack <kossackw@NJC.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: William Kossack <kossackw@NJC.ORG>
Organization: Posted via Supernews, http://www.supernews.com
Subject: Re: format and macros
Content-Type: text/plain; charset=us-ascii
I get the same error when I use $codesc. inside the macro
Floyd Nevseta wrote:
> Ah, your problem is that your macro refers to the numeric format codesc,
> while your format proc created a character format called $codesc. Change
> your macro to the correct reference.
> William Kossack <kossackw@NJC.ORG> on 05/13/2002 11:10:35 AM
> Please respond to William Kossack <kossackw@NJC.ORG>
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: format and macros
> Finally got my usenet access setup at work.....I did not have my code
> with me or the log when
> I posted the original question from home.
> My code seems to be working except for when I try to use a format inside
> a macro I get the following
> NOTE 137-205: Line generated by the invoked macro "CREATE".
> 5 &&varn&x=put(&&varn&x,codesc.);
> ERROR 48-59: The format CODESC was not found or could not be loaded.
> below is the critical part of my sas code. among other conversions I
> need to
> fix data where they have code the text "Little", "Some", "Much", etc into
> the dataset.
> proc format;
> value $codesc "None" = "0"
> "Little" = "1"
> "Some" = "2"
> "Much" = "3"
> "Most" = "4";
> proc contents data=inputdata out=varname (keep=name);
> data _null_;
> set varname nobs=nobs end=end;
> retain cnt 0;
> cnt + 1;
> call symput('varn' || left(cnt), trim(name));
> call symput('vmax',left(cnt));
> %macro create;
> data numdata;
> set inputdata;
> %do x=1 %to &vmax;
> proc print; run;
> "William S. Kossack" wrote:
> > I'm trying to recode a large number of variables.
> > My program would be simple if there were just a few variables. I
> > would first create the format with
> > proc format and then use an assignment statement like
> > var = put(var,format.);
> > However, with more than a hundred variables this is a pain.
> > I've tried using my format inside a macro but I can't get it to work.
> > Any suggestions?
> > --
> > William Kossack
> > email@example.com