@left command

For questions regarding programming in the EViews programming language.

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

Lol38
Posts: 45
Joined: Wed Oct 02, 2013 4:00 pm

@left command

Postby Lol38 » Fri Oct 11, 2013 7:09 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @left command

Postby EViews Gareth » Fri Oct 11, 2013 8:04 pm

@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.

Lol38
Posts: 45
Joined: Wed Oct 02, 2013 4:00 pm

Re: @left command

Postby Lol38 » Fri Oct 11, 2013 8:24 pm

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?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @left command

Postby EViews Gareth » Fri Oct 11, 2013 8:29 pm

You just want the first three digits, no matter what their scale is?

Code: Select all

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

Lol38
Posts: 45
Joined: Wed Oct 02, 2013 4:00 pm

Re: @left command

Postby Lol38 » Sat Oct 12, 2013 4:23 am

Thank you Gareth.

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

Is it possible?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @left command

Postby EViews Gareth » Sat Oct 12, 2013 6:37 am

I don't understand

Lol38
Posts: 45
Joined: Wed Oct 02, 2013 4:00 pm

Re: @left command

Postby Lol38 » Tue Oct 15, 2013 2:53 am

Sorry Gareth, I made a mistake, i wanted the three first digits but the third number must be 3, as you asked.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @left command

Postby EViews Gareth » Tue Oct 15, 2013 7:57 am

You want to change the 3rd digit so that it is always 3?

Code: Select all

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

Lol38
Posts: 45
Joined: Wed Oct 02, 2013 4:00 pm

Re: @left command

Postby Lol38 » Tue Oct 15, 2013 1:08 pm

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!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @left command

Postby EViews Gareth » Tue Oct 15, 2013 1:28 pm

Code: Select all

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

Lol38
Posts: 45
Joined: Wed Oct 02, 2013 4:00 pm

Re: @left command

Postby Lol38 » Tue Oct 15, 2013 2:38 pm

Thank you!!!!!!! That was exactly what i wanted!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest