Page 1 of 1

@recode one series with another if X is greater than Y

Posted: Wed Jun 12, 2024 9:26 am
by bpuffer
Hi!

I am attempting to replace observations from one series with another. So, if and observation for X > Y, make X = Y. However, the following code is throwing an error:

Code: Select all

%ne = "CT MA ME NH NJ NY PA RI VT" %nc = "IA IL IN KS MI MN MO ND NE OH SD WI" %so = "AL AR DC DE FL GA KY LA MD MS NC OK SC TN TX VA WV" %wt = "AK AZ CA CO HI ID MT NM NV OR UT WA WY" for %r NE NC SO WT for %s {%{%r}} %tf = BPPRIV_S{%s} %sf = BP1FH_S{%s} {%sf} = @recode({%sf} > {%tf}, {%tf}, {%sf}) next next
The error is Series assigned to string in "%TF = BPPRIV_SCT" on line 42. Line 42 is the recode line.

Any help would be greatly appreciated!

Re: @recode one series with another if X is greater than Y

Posted: Wed Jun 12, 2024 9:35 am
by EViews Gareth
Are these bits correct:

Code: Select all

%tf = BPPRIV_S{%s} %sf = BP1FH_S{%s}
Its hard to judge what's going on without knowing what the various objects are.

Re: @recode one series with another if X is greater than Y

Posted: Wed Jun 12, 2024 9:59 am
by bpuffer
I believe so, yes. Here's the entire code up to that point. It will run through everything just fine up until the recode line.

Code: Select all

'REGION & DISTRICT DEFINITIONS 'NE %ne = "CT MA ME NH NJ NY PA RI VT" %d1 = "CT MA ME NH RI VT" %d2 = "NJ NY PA" 'NC %nc = "IA IL IN KS MI MN MO ND NE OH SD WI" %d3 = "IL IN MI OH WI" %d4 = "IA KS MN MO ND NE SD" 'SO %so = "AL AR DC DE FL GA KY LA MD MS NC OK SC TN TX VA WV" %d5 = "DC DE FL GA MD NC SC VA WV" %d6 = "AL KY MS TN" %d7 = "AR LA OK TX" 'WT %wt = "AK AZ CA CO HI ID MT NM NV OR UT WA WY" %d8 = "AZ CO ID MT NM NV UT WY" %d9 = "AK CA HI OR WA" pageselect M for %f %s ??BPPRIV BPPRIVNS_S?? ??BP1FH BP1FHNS_S?? 'HOUSTNENSA HSNS_NE HOUSTNE HS_NE HOUSTMWNSA HSNS_NC HOUSTMW HS_NC HOUSTSNSA HSNS_SO HOUSTS HS_SO HOUSTWNSA HSNS_WT HOUSTW HS_WT HOUSTNE1FNSA HONS_NE HOUSTNE1F HO_NE HOUSTMW1FNSA HONS_NC HOUSTMW1F HO_NC HOUSTS1FNSA HONS_SO HOUSTS1F HO_SO HOUSTW1FNSA HONS_WT HOUSTW1F HO_WT copy(o) FRED::{%f} {%s} next for %c BP1FH BPPRIV {%c}NS_SDC.ipolate {%c}NS_SDC_I series {%c}NS_SDC = {%c}NS_SDC_I delete {%c}NS_SDC_I for %r NE NC SO WT for %s {%{%r}} {%c}NS_S{%s}.x13 @arima @seats series {%c}_S{%s} = {%c}NS_S{%s}_S11 delete {%c}NS_S{%s}_S11 next next next for %r NE NC SO WT for %s {%{%r}} %tf = BPPRIV_S{%s} %sf = BP1FH_S{%s} {%sf} = @recode({%sf} > {%tf}, {%tf}, {%sf}) next next

Re: @recode one series with another if X is greater than Y

Posted: Wed Jun 12, 2024 10:04 am
by EViews Gareth
It looks like BPPRIV_S{%s} is a series? So you're setting a string equal to a series?

Re: @recode one series with another if X is greater than Y

Posted: Wed Jun 12, 2024 12:00 pm
by bpuffer
I am trying to set a series equal to a series, but only for the observations that meet the qualifications. So, in months where BP1FH_S{%s} > BPPRIV_S{%s} make BP1FH_S{%s} in those months equal to BPPRIV_S{%s}.

Re: @recode one series with another if X is greater than Y

Posted: Wed Jun 12, 2024 1:16 pm
by EViews Gareth
Then you will need to change the lines:

Code: Select all

%tf = BPPRIV_S{%s} %sf = BP1FH_S{%s}
Perhaps something like:

Code: Select all

%tf = BPPRIV_S{%s}.@name %sf = BP1FH_S{%s}.@name

Re: @recode one series with another if X is greater than Y

Posted: Thu Jun 13, 2024 12:50 pm
by bpuffer
That worked. Thank you.