BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eemrun
Obsidian | Level 7

simple issue driving me nuts!

 

I am trying to do a log-ratio transformation on a variable before regression. The variable is an index (so has values like 450, 560, 1200, etc.). i am doing this in the following way:

 

var1_T = log(var1/lag(var1))

I want to bring the transformed value to its original form. So wanted to do inverse log like:

 

var1_FCT_Orig = exp(var1_T);

Not working. Can anyone tell me where I am doing this wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

When answers don't meet your assumptions, check your assumption. 


EXP is the reverse of LOG. 

So it gives you: 

var1 / lag(var1)

 

If you want Var1 then you need to multiple by the lag of VAR1 as well. 

 

var1_t = log(var1 / lag(var1) );

var1_fct_orig = exp(var1_t) * lag(var1);

The question is, do you have the lagged value to work with as well...



@eemrun wrote:

simple issue driving me nuts!

 

I am trying to do a log-ratio transformation on a variable before regression. The variable is an index (so has values like 450, 560, 1200, etc.). i am doing this in the following way:

 

var1_T = log(var1/lag(var1))

I want to bring the transformed value to its original form. So wanted to do inverse log like:

 

var1_FCT_Orig = exp(var1_T);

Not working. Can anyone tell me where I am doing this wrong?



View solution in original post

3 REPLIES 3
Reeza
Super User

When answers don't meet your assumptions, check your assumption. 


EXP is the reverse of LOG. 

So it gives you: 

var1 / lag(var1)

 

If you want Var1 then you need to multiple by the lag of VAR1 as well. 

 

var1_t = log(var1 / lag(var1) );

var1_fct_orig = exp(var1_t) * lag(var1);

The question is, do you have the lagged value to work with as well...



@eemrun wrote:

simple issue driving me nuts!

 

I am trying to do a log-ratio transformation on a variable before regression. The variable is an index (so has values like 450, 560, 1200, etc.). i am doing this in the following way:

 

var1_T = log(var1/lag(var1))

I want to bring the transformed value to its original form. So wanted to do inverse log like:

 

var1_FCT_Orig = exp(var1_T);

Not working. Can anyone tell me where I am doing this wrong?



eemrun
Obsidian | Level 7
thanks! that worked perfectly.
PGStats
Opal | Level 21

You have everything you need in the transformed series, except the starting value, Example:

 

title 'Logistic Growth Curve Model of U.S. Population';
data uspop;
   input pop @@;
   retain year 1780;
   year=year+10;
   logPopRatio = log(pop/lag(pop));
   label pop='U.S. Population in Thousands';
   datalines;
3929  5308  7239   9638  12866  17069  23191  31443  39818 50155
62947 75994 91972 105710 122775 131669 151325 179323 203211
226542 248710
;

data usNewPop;
set uspop;
retain lagNewPop;
if _n_ = 1 
    then NewPop = 3929;
    else NewPop = exp(logPopRatio)*lagNewPop;
lagNewPop = NewPop;
drop lagNewPop;
run;

proc print; run;
PG
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 5672 views
  • 3 likes
  • 3 in conversation