Date: Fri, 12 Feb 2010 01:12:51 -0800
Reply-To: xlr82sas <xlr82sas@AOL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: xlr82sas <xlr82sas@AOL.COM>
Subject: Re: Character to Numeric variable conversion
Content-Type: text/plain; charset=ISO-8859-1
On Feb 11, 12:22 pm, jim.1s...@YAHOO.COM (Jim Groeneveld) wrote:
> Hi Yaw,
> I wrote a macro that 'converts' character variables into numeric ones by
> firstly copying the other type result in another variable that is renamed to
> the original name later. So from a user point of view, calling the macro it
> really looks like type conversion.
> Additionally the original variable label, format and informat are retained
> (copied), the format names are just changed ($ removed); I once have to
> interpret and adapt the actual formats themselves, this is still left to the
> Furthermore there may be non-numerics in the character data, like 'NA', 'M',
> or whatever. These character values can be assigned any desired numeric
> values (missings as well) during the macro call.
> The macro is available as:http://jim.groeneveld.eu.tf/software/SASmacro/aRecodeN.zip
> See alsohttp://listserv.uga.edu/cgi-bin/wa?S2=sas-l&q=aRecodeN&s=&f=&a=2002&b=
> Regards - Jim.
> Jim Groeneveld, Netherlands
> Statistician, SAS consultanthttp://jim.groeneveld.eu.tf
> On Tue, 9 Feb 2010 13:12:32 -0800, Yaw <link...@GMAIL.COM> wrote:
> >Dear Community:
> >I have this dataset with character variables I want to convert to
> >numeric. The data points are all numeric but for some reason they are
> >being read as character.
> >So I tried converting them by using charvar*1 or Charvar +0. Proc
> >contents told me they have been converted(into numeric) but when I run
> >a proc means on the variables I see the vars as missing mean sd etc
> >and N of 0.
> >Can somebody tell me what's amiss here? Any ideas? Thanks in advance.
> >id mx
> > 1 .
> > 2 0.53
> > 5 .
> >12 15 .5
> >13 .
> > etc.- Hide quoted text -
> - Show quoted text -
You can alwasy use SQL. There also may be a way using aliases in proc
table num as
input(one,1.) as one
,input(two,1.) as two
,input(tre,1.) as tre
,input(for,1.) as for