Date: Mon, 21 Nov 2005 13:36:04 -0500
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: How to add decoded variables.
Content-Type: text/plain; charset="us-ascii"
Assuming you do need to do this -- one reason would be if you want to
export your SAS data to some other package and keep both the "raw" and
formatted values -- this is a challenging, but doable, assignment.
Ian's template should help you get started.
If you are using SAS 9, take a look at the SASHELP.VFORMAT view. This
provides information about all formats, and should enable you to
distinguish between builtin and user-defined formats, since you state
that you only want the extra variable for the latter. (There are many
builtin formats, of course.)
You'll also need to get the variables into your desired order, and to
get the correct length for each of the new __d variables.
If I am understanding your specification correctly, you want to generate
code like the final DATA step below.
'F' = 'Female'
'M' = 'Male'
Other = '???'
FORMAT Sex $SexFmt.;
/* RETAIN used to get the desired order */
RETAIN Name Sex Sex__D Age Height Weight;
LENGTH Sex__D $ 6;
Sex__D = PUTC(Sex,VFORMAT(Sex));
From: firstname.lastname@example.org [mailto:email@example.com]
On Behalf Of SAS_my_life
Sent: Monday, November 21, 2005 11:21 AM
Subject: How to add decoded variables.
Hello guys I need to something like this can you help me how exactly to
Add one variable for every variable in the source dataset which has a
user-defined format. The new variable will contain the decoded value
and be located next to the original variable, with __d appended to the
variable name. The log will inform the user if the format was not found
or if the particular value was not found for the given format.
proc sort data=dslist out=fixcode;
by memname name;
* where format not in (' ', '$');
set fixcode end = eof;
call symput('newname'||compress(put(_n_, 4.)),
I started doing some thing like this but this is not working , I
appriciate any kind of help.