Converting a Number into String

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

franciscoA
Posts: 10
Joined: Fri Oct 25, 2013 6:49 am

Converting a Number into String

Postby franciscoA » Tue Sep 16, 2014 7:20 am

This should be fairly simple. I'm trying to convert a numeric field into a string.

series FieldName = @str(CustomerNumber)
I get an error message: Can not assign string expression to numeric variable in...

The CustomerNumber is a number between 10 and 15 digits. It is also used to give structure to the series in panel data.

What could be the problem?

startz
Non-normality and collinearity are NOT problems!
Posts: 3796
Joined: Wed Sep 17, 2008 2:25 pm

Re: Converting a Number into String

Postby startz » Tue Sep 16, 2014 7:28 am

alpha FieldName rather than series FieldName

franciscoA
Posts: 10
Joined: Fri Oct 25, 2013 6:49 am

Re: Converting a Number into String

Postby franciscoA » Tue Sep 16, 2014 7:37 am

Thank you. That worked. But I can still solve my problem. The string is being written as scientific notation. What I'm actually trying to do is to get the last four digits:
alpha FieldName = @str(CustomerNumber)

series NewCustomer = @right(FieldName, 4)

returns = e+13

startz
Non-normality and collinearity are NOT problems!
Posts: 3796
Joined: Wed Sep 17, 2008 2:25 pm

Re: Converting a Number into String

Postby startz » Tue Sep 16, 2014 7:40 am

Take a look at the Help system documentation for @str. You can supply a format specification that might give you what you want.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests