Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 01-12-2005, 09:31 PM
Chang Y. Chung
Guest
 
Posts: n/a
Default Re: SAVE to a new dataset with formatted values ??

On Wed, 12 Jan 2005 17:10:55 -0500, Werner HELM <Werner.E.Helm@GMX.DE> wrote:

>Hi all :
>
>I have a SAS dataset OLD with formatted variables.
>How do I best create a new dataset NEW where in NEW the formatted
>values permanently replace the original ones, so that when using the new
>dataset I get the same formatted "look" at the data without the need to
>apply formats ?? I guess I knew it 10 years before, but ....


Hi, Werner,

In the sas release 9, you have a pair of wonderful functions, vvalue() and
vvaluex(), which return the formatted values as a character string. So, you
can do something like below.

Just remember that by applying formats, you are creating character strings
instead of numbers. If the original variable is of numeric type, then you
cannot just "replace" it with a character type variable.

I saw people keeping both the variables in a data set: one stores numeric
values as they are and another stores the formatted character string values
(in most cases "value labels") -- I always envy those people who have large
enough memory and fast enough processing speed to do this. :-)

Cheers,
Chang

data old;
attrib var1 format=words30.;
drop i;
do i = 1 to 3;
var1 = 10**i;
output;
end;
run;

data new;
set old;
cVar1 = vvalue(var1);
run;
proc print data=new;
format var1; /* to see the raw values instead of formatted values */
run;
/* on lst
Obs var1 cVar1

1 10 ten
2 100 one hundred
3 1000 one thousand
*/
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: processing sas dataset label values?? data _null_, Newsgroup comp.soft-sys.sas 0 10-19-2007 03:58 PM
SAVE to a new dataset with formatted values ?? Werner HELM Newsgroup comp.soft-sys.sas 2 01-12-2005 10:05 PM
Re: How to output both formatted and unformatted values with onePROC SQL? Howard Schreier Newsgroup comp.soft-sys.sas 0 11-02-2004 03:19 PM
Re: How to output both formatted and unformatted values with onePROC SQL? Terjeson, Mark Newsgroup comp.soft-sys.sas 0 11-01-2004 03:46 PM
How to output both formatted and unformatted values with one PROCSQL? Vladimir Grechko Newsgroup comp.soft-sys.sas 0 11-01-2004 03:17 PM



All times are GMT. The time now is 09:39 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.