Hi everyone,
I have two of what I assume are basic questions.
1. I'm required to calculate the delta of variables i.e the changes in the variables from one fiscal year to the other. May I know the best way to handle this?
2. With other Softwares, like stata, there is a function one can use to indicate that their data is a panel one. My question: Is a there a function like that in SAS and does it matter if it is not indicated to SAS that the data is a panel one?
Thank you very much and I look forward from hearing from you.
Does the following reflect what you want to accomplish?:
data have; input fiscal_year x; cards; 2000 5 2001 3 2002 . 2003 1 2004 3 2005 2 ; data want; set have; delta=x/lag(x)-1; run;
Art, CEO, AnalystFinder.com
Here is an example to show you how to get fiscal year ( start from 01july).
data have;
do date='01jan2010'd to '01jan2014'd;
do stock=1 to 10;
ret=rand('normal');
ret1=rand('normal');
output;
end;
end;
format date date9.;
run;
data have;
set have;
year=year(intnx('year.7',date,0,'b'));
run;
proc sort data=have;
by stock year;
run;
Dear KSharp,
Thank you for the reply.
Actually, I'm not trying to get a fiscal year. I rather want to calculate the delta(change) of variables from one fiscal year to the other.
Eg.
fiscal year variable(x)
2000 5
2001 3
2002 .
2003 1
2004 3
2005 2
How to you calculate the delta(changes) in x for each of the fiscal years?
Thanks
Does the following reflect what you want to accomplish?:
data have; input fiscal_year x; cards; 2000 5 2001 3 2002 . 2003 1 2004 3 2005 2 ; data want; set have; delta=x/lag(x)-1; run;
Art, CEO, AnalystFinder.com
SAS has a panel procedure (in SAS/ETS).
Other than that, proc transpose is available to make files long or wide, and one can take advantage of number of statements and functions to calculate deltas depending upon how the data is structured (e.g., using arrays, the retain statement, or the lag function).
Art, CEO, AnalystFinder.com
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.