Thnaks for the reply, I want to make a pattern of replacing, for example: series h replace with seies j if series f(7)<>na and this keep continous for all the series that are more than 500 series. if the order of my series are like this: f g h j k m n q u v x z (repeats from 1984 to 2013). then I write the codes like this:
series pc_merged1=@recode(pc_clf1984(7)<>na, pc_clh1984, pc_clj1984)
series pc_merged2=@recode(pc_clg1984(7)<>na, pc_merged1, pc_clk1984)
series pc_merged3=@recode(pc_clh1984(7)<>na, pc_merged2, pc_clm1984)
series pc_merged4=@recode(pc_clj1984(7)<>na, pc_merged3, pc_cln1984)
series pc_merged5=@recode(pc_clk1984(7)<>na, pc_merged4, pc_clq1984)
series pc_merged6=@recode(pc_clm1984(7)<>na, pc_merged5, pc_clu1984)
series pc_merged7=@recode(pc_cln1984(7)<>na, pc_merged6, pc_clv1984)
series pc_merged8=@recode(pc_clq1984(7)<>na, pc_merged7, pc_clx1984)
series pc_merged9=@recode(pc_clu1984(7)<>na, pc_merged8, pc_clz1984)
series pc_merged10=@recode(pc_clv1984(7)<>na, pc_merged9, pc_clf1985)
series pc_merged11=@recode(pc_clx1984(7)<>na, pc_merged10, pc_clg1985)
..........
and it keep continou until 2013.
in order to make it short I creat loops for that in this way:
for !j = 1984 to 2013
for %i h j k m n q u v x z
for %s j k m n q u v x z
for %t f g h j k m n q u v x z
%name1= "PC_CL" + @upper(%i) + @str(!j)
%name2 = "PC_CL" + @upper(%s) + @str(!j)
%name3 = "PC_CL" + @upper(%t) + @str(!j)
series pc_merged1 = @recode({%name3}(7)<>na, {%name1}, {%name2})
next
next
next
next
according to the above code my merged data series should start from pc_clh1984 and end up at pc_clz2013. and the rules is that each series should replace to the next series if 2 series before that is in 7 observation before its expiration, and this should continou for all the series. but I dont undrestand why these codes (both the long one and the loop one)dont work and generate a series that start from 2007 with lotfs of missing values and mess. if you can help me to correct the codes i would be very thankful.
Looking forward to hear from you
You're going to have to be a bit clearer about what you want to do.
Right now, each time through the loop we create a %name of the form "PC_CL" plus the elements of the %s loop plus the string representation of the number.
As in the first three times through the loop you'll have
"PC_CLF1984" "PC_CLS1984" "PC_CLH1984"
Now I'm not sure what the roll of %t is in the comparison to follow. I don't *think* you want it as a nested loop, but that's just a guess. Over what comparison variables are you going to be doing the recode? Is there a pattern to the choice?