LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (December 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Dec 2008 22:16:33 -0500
Reply-To:     "A.B." <alicia.bingo@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "A.B." <alicia.bingo@GMAIL.COM>
Subject:      Re: Convert and store format value into a character variable
Comments: To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@dshs.wa.gov>
In-Reply-To:  <941871A13165C2418EC144ACB212BDB0BEB230@dshsmxoly1504g.dshs.wa.lcl>
Content-Type: text/plain; charset=ISO-8859-1

I was trying to get a bunch of crosstabs using a SAS macro . The format for each of the variables were messed up when I put the result tables (from ODS output) together. I think it is because the formats are all numeric and SAS just uses the format for the first variable.

Your and Randy's solution: The newCharVar=put(gender, sex.); gender_formatted = put(gender,sexfmt.); is what I was looking for. I just need to get the format from the format library for each variable. I think that's what was suggested in the sas comm wiki page Ronald mentioned. I will try that at work tomorrow.

Thank you all for your help! A.B.

On Wed, Dec 3, 2008 at 5:30 PM, Nordlund, Dan (DSHS/RDA) < NordlDJ@dshs.wa.gov> wrote:

> > -----Original Message----- > > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > > Behalf Of A.B. > > Sent: Wednesday, December 03, 2008 1:59 PM > > To: SAS-L@LISTSERV.UGA.EDU > > Subject: Convert and store format value into a character variable > > > > Hi, > > > > I was wondering if there's a way to convert/store format value into a > > character variable. An example: > > > > Gender is a numeric variable and has tow values with the > > following format: > > 1=Male 2=Female > > > > I want to use the format value (not the value of the > > variable) in some way. > > How can I achieve that? > > > > Thanks! > > -- > > A.B. > > > > Here is one way: > > Proc format: > value sexfmt > 1 = 'Male' > 2 = 'Female' > ; > Run; > > Data want; > set have; > length gender_formatted $6; > gender_formatted = put(gender,sexfmt.); > Run; > > > Having said that, you can probably achieve what you want without creating > an additional variable. So, exactly what are you trying to do? > > Dan > > Daniel J. Nordlund > Washington State Department of Social and Health Services > Planning, Performance, and Accountability > Research and Data Analysis Division > Olympia, WA 98504-5204 >

-- Thanks, A.B.


Back to: Top of message | Previous page | Main SAS-L page