BookmarkSubscribeRSS Feed
PANVAS
Calcite | Level 5

Hello guys. i faced a problem during my thesis calculations. i am working on something complicate and its my first time that i am using sas for my regression analysis. my problem is that i want to calculate sales growth and i already create the table with the variable sales. But, my data is vertically and i have the permno column and the sales column and as you understand i am working on 1500 companies and 20 years per each. i have no idea how to calculate the sales growth for my groups.

5 REPLIES 5
ballardw
Super User

You should post a few lines of what your data looks like and how the variables are to be used. We really have no idea what a "permno" column might be without details.

Do you have a variable describing your "groups"?  Or a format that may do that?

Is your date related data in SAS date value variables? This may be important if you have data at other than yearly values.

 

PANVAS
Calcite | Level 5

my data is like that:

gvkey,  fiscal year, sales
1004     1992           200
1004     1993           220
1004     1994           210
1005     1992           355
1005     1993           400
1006     1992           412
1006     1993           500
1007     1992           1520
1007     1993           1580
1007     1994           2000
1007     1995           1890
1007     1996           1400

 

this is a small sample of my whole data table. gvkey is the id number of each firm.

Reeza
Super User

What do you want your output to look like?

PANVAS
Calcite | Level 5

gvkey,  fiscal year, sales  sales growth
1004     1992           200           -
1004     1993           220          0.1
1004     1994           210           e.t.c
1005     1992           355
1005     1993           400
1006     1992           412
1006     1993           500
1007     1992           1520
1007     1993           1580
1007     1994           2000
1007     1995           1890
1007     1996           1400

 

i want to create a new varible for each fiscal year calculated the sales growth of each company.

Reeza
Super User

You'll need a couple of things:

1. A way to identify the start of each company (BY GVKEY)

2. A way to reference the previous observation (LAG/DIF Function)

3. You'll have to check your data - do you need to account for missing years somehow? I'll leave that as an exercise for you at the moment.

 

data have;
input gvkey  fiscal_year sales ; 
cards;
1004     1992           200
1004     1993           220
1004     1994           210
1005     1992           355
1005     1993           400
1006     1992           412
1006     1993           500
1007     1992           1520
1007     1993           1580
1007     1994           2000
1007     1995           1890
1007     1996           1400
;
run;

data want;
set have;
by gvkey;

lag_sales=lag1(sales);
if first.gvkey then growth=.;
else growth=(sales-lag_sales)/lag_sales;

format growth percent8.1;

run;

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1517 views
  • 0 likes
  • 3 in conversation