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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

View solution in original post

5 REPLIES 5
Ksharp
Super User

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;
Theo_Gh
Obsidian | Level 7

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

 

art297
Opal | Level 21

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

Theo_Gh
Obsidian | Level 7
I think that'll do art297. I thought there was a code like it is in stata, specifically for delta.
Do you any opinion on my other question. Thanks
art297
Opal | Level 21

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

 

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2452 views
  • 2 likes
  • 3 in conversation