Page 1 of 1

@left command

Posted: Fri Oct 11, 2013 7:09 pm
by Lol38
Hello,

I would like to know what is the mistake i´m making with the use of this command since every time i use it, EViews tells me "numeric argument passed to string @left function".

I´m working in this way:

series job
job = @left (ocup, 3)

My sample is: OCUP

1 10313
2 10313
3
4 99997
5 20311
6
7
8 80311
9
10
11
12
13 20312
14 30314
15 5002
16 40312
17 82314
18
19 34323
20 80323
21
22
23 92312
24
25
26
27 30314
28
29
30
31
32 55314
33 80313
34
35
36
37 81332
38
39
40
41
42
43 50111
44
45
46 40313
47 53314
48
49
50
51 34323
52 53314
53 53314
54 53314
55
56
57
58
59
60
61
62 56313
63
64
65
66 6001
67 41312
68
69
70
71
72 82113
73 55314
74
75 10313
76 30313
77 32314
78
79
80 31313
81
82 99999
83
84
85
86 57112
87
88
89 40311
90 30313
91
92
93
94
95
96
97 53203
98 53314
99 72111
100 7001


Thank you.

Re: @left command

Posted: Fri Oct 11, 2013 8:04 pm
by EViews Gareth
@left is a string function. It works on string objects, string variables and alpha series. It returns string objects, string variables and alpha series.

You appear to be using it on a numerical series and expecting it to return a numerical series.

I'm not sure what you're trying to do.

Re: @left command

Posted: Fri Oct 11, 2013 8:24 pm
by Lol38
Hello Gareth,

First of all, thank you.

Yes, i was expecting a numerical series from a numerical series.

What can I do or use in order to get the first three numbers from my numeric series?

Re: @left command

Posted: Fri Oct 11, 2013 8:29 pm
by EViews Gareth
You just want the first three digits, no matter what their scale is?

Code: Select all

series job = @val(@left(@str(ocup),3))

Re: @left command

Posted: Sat Oct 12, 2013 4:23 am
by Lol38
Thank you Gareth.

But now, i want that the third number only be 3, eg. 803, 703, 653 and so on

Is it possible?

Re: @left command

Posted: Sat Oct 12, 2013 6:37 am
by EViews Gareth
I don't understand

Re: @left command

Posted: Tue Oct 15, 2013 2:53 am
by Lol38
Sorry Gareth, I made a mistake, i wanted the three first digits but the third number must be 3, as you asked.

Re: @left command

Posted: Tue Oct 15, 2013 7:57 am
by EViews Gareth
You want to change the 3rd digit so that it is always 3?

Code: Select all

series job = @val(@left(@str(ocup),2)+"3")

Re: @left command

Posted: Tue Oct 15, 2013 1:08 pm
by Lol38
no, i just want the three first numbers but only in those lines where the third number is three.

I think the best will be create a dummy with the first series you helped me create. Is that correct?

Thank you Gareth!

Re: @left command

Posted: Tue Oct 15, 2013 1:28 pm
by EViews Gareth

Code: Select all

smpl if @mid(@str(ocup), 3, 1) = "3"

Re: @left command

Posted: Tue Oct 15, 2013 2:38 pm
by Lol38
Thank you!!!!!!! That was exactly what i wanted!