LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 19 Oct 2006 04:43:26 -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: Save formats permanently?
Comments: To: "N. Knese" <n.knese@GMX.DE>
Content-Type: text/plain; charset=ISO-8859-1

Dear Nicole,

What you want may be possible in two ways:

1. Create an extra (character) variable to hold the formatted value of the Value variable: FmtValue = PUT (RawValue, ApplFmt.); Then delete the raw Value variable. This way you get different (character) values between (combined) records, where you initially had same raw values. I do not so much see the use of this when presented as a FREQ table.

2. Add an extra variable ValueFmt in which you store the name of the associated format (differing between original datasets): ValueFmt = VFORMAT ( variable ); The format name also determines the type of the original variable. Then at a later stage you can always use the format (that should remain available) from its name (in your dataset) using the PUTN and PUTC functions. You should disassociate the posibly associated format from the Value variable. this is what I once did to store all kinds of data in one dataset.

Regards - Jim. -- Jim Groeneveld, Netherlands Statistician, SAS consultant home.hccnet.nl/jim.groeneveld

On Thu, 19 Oct 2006 09:09:11 +0200, N. Knese <n.knese@GMX.DE> wrote:

>Hi, >that's not exactly what I meant. An example: After having run the macro I have two dataset containing the variables var (variable name), value, N, percent with one ore more observations (depending on the number of values and this is the problem). For dataset 1 the values are for example 1=yes, 2=no, 3=missing, for dataset 2 the values are 1=good, 2=better, 3=best. But I don't want to have the values (numbers) in my combined table but the value labels (yes, no, etc.). As I can only have one format for a variable (in this case the variable value) I wondered if I couldn't save the labels permanently (in an extra character variable for example). >Anybody an idea? >Nicole. >-------- Original-Nachricht -------- >Datum: Wed, 18 Oct 2006 21:16:31 -0400 >Von: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> >An: SAS-L@LISTSERV.UGA.EDU >Betreff: Re: Save formats permanently? > >> On Wed, 18 Oct 2006 09:48:33 +0200, N. Knese <n.knese@GMX.DE> wrote: >> >> >Hi all, >> > >> >due to the very helpful solutions to my last question (thanks to all who >> answered) another problem has come up in my program. >> >I have got a macro running through several variables of a table doing a >> PROC FREQ (writing the result in a separate table). Up to this point >> everything works perfectly. Now I would like to append these single tables >> to one huge table. The problems that comes up is that the variables from >> the >> preq procedure have different formats and SAS refuses to append them. >> >> There's a lot of guessing to be done, since you did not provide any data, >> code, or log excerpts. >> >> In my experience, SAS does not let *format* differences be an obstacle in >> combining data. So I suspect that you really don't mean "format". >> >> My guess is that you are doing something like this: >> >> proc freq data=sashelp.class noprint; >> tables age / out=age_freq; >> tables sex / out=sex_freq; >> run; >> >> data all; >> set age_freq(rename=(age=stratum) ) >> sex_freq(rename=(sex=stratum) ); >> run; >> >> The result in the log: >> >> ERROR: Variable stratum has been defined as both character and numeric. >> >> That's because AGE is numeric and SEX is character, a conflict of *type* >> rather than *format*. >> >> You could add a bunch of DATA step code to build STRATUM as a new >> character >> variable and convert all of the numerics when populating it. Before going >> in >> that direction, why not try something like >> >> proc tabulate data=sashelp.class; >> class age sex; >> table (age sex),(n pctn)*f=6.; >> run; >> >> Would that meet the requirement? >> >> >Is it maybe possible to store the "absolute" formats in the variables or >> has anybody got another idea how to solve this problem? >> > >> >Thanks in advance! >> >Nicole. >> >-- >> >GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist! >> >NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl > >-- >GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist! >NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl


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