Page 1 of 1

Coding to Return Different Values

Posted: Wed Sep 04, 2013 8:06 am
by RPEDC
Hello,

I'm working on a program where I have a series of countries where each country has two variables that I want to create an identity out of. I'd also like to write the program so it returns "NA" if the identity equals one of the values (I know that some of the countries are missing the second piece of data). What I coded is below, but it's not quite working out. I'm wondering anyone has some suggestions.

Code: Select all

for %i USA AFG ALB ALG ANG AGL ANT ARG ARM ARU AUST ASTR AZE BAHA BHR BAN BAR BYE BEL BELI BEN CAN COL COM CON ZAI FIN FRA smpl @all series {%i}_A_B = na smpl if {%i}_A_B = na genr {%i}_A_B = {%i}_A - {%i}_B if {%i}_A_B ={%i}_A then {%i}_A_B= NA endif next

Re: Coding to Return Different Values

Posted: Wed Sep 04, 2013 8:16 am
by startz
something like

Code: Select all

{%i}_A_B = @recode({%i}_A_B ={%i}_A, na, {%i}_A_B)