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.
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.
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.
What do you want your output to look like?
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.
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.