Greetings,
I am having trouble with the following for loop. I would like to make every 12th observation equal to a certain number:
create u 500
series myvar = 0
for !i = 1 to 30 step 12
series myvar(!i) = 5
next
but when I run this code, every single observation, for the whole length of the series, gets assigned the number 5.
Any help would be appreciated.
Thanks in advance,
- cap
For loops
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: For loops
setting myvar(!i) = 5 doesn't actually set the !ith value of myvar equal to 5, it sets the entire series (with a lead of !i) equal to 5.
Perhaps the easiest way to do what you want is with a simple @recode, using the @trend function:
series myvar = @recode(@mod(@trend,12)=0,5,0)
Perhaps the easiest way to do what you want is with a simple @recode, using the @trend function:
series myvar = @recode(@mod(@trend,12)=0,5,0)
Who is online
Users browsing this forum: No registered users and 2 guests
