Date: Mon, 13 May 2002 09:10:35 -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
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.);
-------
48
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";
run;
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));
run;
%macro create;
data numdata;
set inputdata;
%do x=1 %to &vmax;
&&varn&x=put(&&varn&x,codesc.);
%end;
run;
%mend;
%create;
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
> wskossack@attbi.com