08-05-2014 11:16 AM
I have an index from 1991-2013.
Because they are all over the place, I have manually looked into them to assign portfolios for them each year.
I have divided the pfo into 3 pfos each year and want to write a code for it but don’t know how to.
For example I want to write something like the below for 1991-2013.,
data f2; set f1;
if pfoyr=1991, and index<-1.22 then pfo=1, -1.22=<index<=2.48 then pfo=2, and index >2.48 then pfo=3;
Could you kindly let me know how to write such a code?
08-05-2014 11:23 AM
Perhaps you need an if/else construct:
if pfoyr=1991 and index < -1.22 then pfo=1;
else if pfoyr=1991 and -1.22 <= index <= 2.48 then pfo=2;
else pfo=3; /* Ommitted the code as all over 2.48 will come out here */
08-06-2014 03:26 AM
The value of "pfo" depends on the variables pfoyr and index, right? So for different years, different index-values need to be checked.
If those assumptions are right, try this:
low -< -1.22 = 1
-1.22 - 2.48 = 2
2.48 <- high = 3
length pfo 8 FmtName $ 32;
FmtName = cats('Index', pfoyr, 'Fmt.');
pfo = inputn(index,FmtName);