Page 1 of 1

something like str2num ?

Posted: Thu Dec 04, 2014 2:19 pm
by alex7312
1 I have a series with numbers stored as string (for some reason that is how they were imported from xls / although in xls they are stored as numbers).
How to convert the whole series in number format?

Otherwise I receive the following info: "alpha series in specification DUM_POZICIJA (name of my problematic series) @expand can convert to categorical dummies"

2 The series was made with the program>
smpl @all

alpha dum_pozicija="4"

dum_pozicija= @recode(poz01 ="18" or poz01="23","1",dum_pozicija)
dum_pozicija= @recode(poz01 ="1" or ...,"2",dum_pozicija)
etc...

But if I tried to use numbers (4) instead of strings ("4") I receive a message "cannot assign numeric expression to string variable in "alpha dum_pozicija=4".
Can I somehow define numbers in the above program?

Re: something like str2num ?

Posted: Thu Dec 04, 2014 2:32 pm
by EViews Gareth
@val

Re: something like str2num ?

Posted: Thu Dec 04, 2014 3:04 pm
by alex7312
thanks!
Suppose it refers to second part?
It does not refer to converting the whole series to numbers? Because if I apply to whole series @val(nameofseries) it returns numbers and n/a...

Re: something like str2num ?

Posted: Thu Dec 04, 2014 3:34 pm
by EViews Gareth
@val will convert a whole alpha series, or a single character, into a number. Any text that doesn't represent a number will be converted into an NA.