Date: Thu, 14 May 2009 09:14:39 -0700
Reply-To: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject: Re: Looking for a macro or code to convert char to numeric while
Content-Type: text/plain; charset="iso-8859-1"
To add a little to Joe's excellent suggestion:
Enter the 25 variable names into the rename and input lines below and change the YOURFILE references.
proc contents data=YOURFILE out=varlist(keep=name varnum) noprint; run;
select name into :namelist separated by ' ' from varlist order by varnum;
One thing for you to think about - it's usually simpler to read the data correctly in the first place - if this is imported somehow there are usually ways to instruct the program to read the data correctly and avoid this problem.
Hope that helps -
DDS Data Extraction
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Thomas Fröjd
Sent: Thursday, May 14, 2009 7:33 AM
Subject: Re: Looking for a macro or code to convert char to numeric while retaining order.
Only 25 of about 150 variables should be converted. Theese are variables
that contain numbers between 0 and 9 usually. I dont want to convert all
character variables since i have some that contains text.
Gerhard Hellriegel skrev:
> depends on some further information: should ALL character variables been
> converted? Are they all standard numerics or something like time,
> date, ...? Should the names be the same or changed?
> A few informations would be nice.
> On Thu, 14 May 2009 11:26:04 +0200, =?ISO-8859-1?Q?Thomas_Fr=F6jd?=
> <thomas.frojd@NEURO.UU.SE> wrote:
>> Hi, I have a large data set where about 20 variables have been
>> mistankenly read in as character variables. I would like to convert them
>> to numeric while still retaining the old order of the variables. Anyone
>> have some code I can use for this? I figure it should be a quite common
>> Best regards!