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 (March 1997, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 7 Mar 1997 12:21:10 -0600
Reply-To:     came.s@GHC.ORG
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         came.s@GHC.ORG
Organization: Deja News Usenet Posting Service
Subject:      Re: Converting numeric to character

In article <1997Mar6.234923@msuvx1.memphis.edu>, jnickey@cc.memphis.edu (John Nickey) wrote: > > Is there a simple way to change a set of numeric variables to a set of > character variables? For instance, I have a set of numeric variables, > q1 to q25, and want to change them to character variables, q1 to q25. > Thanks immensely. > > John Nickey

Try this, John...

/* First, compile the following macro, which is needed to generate code for within a RENAME= dataset option: **/

%macro renvars(nvars); %do i = 1 %to &nvars; q&i = _q&i %end; %mend renvars;

/* Next, assign values to two macro variables: **/

%let numv=25; /* number of numeric variables input */ %let precis=10; /* precision of numeric values written into char vars */

/* Then, code the following datastep... **/

data outdata(drop=_q: i); array _q{&numv}; array q{&numv} $ &precis; set indata(rename=(%renvars(&numv))); do i = 1 to &numv; q[i] = compress(_q[i]); end; run;

/* <<end of code>> */

Good luck...

Scott Came Sr Programmer/Analyst Group Health Cooperative of Puget Sound Seattle

-------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet


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