data TOPCOM_TIC; set Q_COMP_SHORT10_18;
keep TIC CEQQ ATQ COM_EQ;
COM_EQ = CEQQ/ATQ;
run;
proc sort data=TOPCOM_TIC ;
BY descending TIC COM_EQ;
RUN;
proc means data=TOPCOM_TIC;
var COM_EQ ; BY TIC ;
output out=avg_CE
mean=avg_CE_TIC;
run;
Proc freq data=TOPCOM_TIC;
by COM_EQ ;
table TIC /out=Q6;
run;
data Q6; set Q6;
if COM_EQ>=50 ;
run;
What do you mean by "not running"? I.e., what is the sas log telling you? If we could see the log, we might be able to provide more effective assistance.
However, to see if I understand the object: you want to calculate for each firm (variable TIC), the average ratio of quarterly reports of common equity (CEQ) to total assets (ATQ), right? It looks to me like you are using COMPUSTAT data.
To do this you, don't need to sort - you can use the CLASS statement in proc means to get averages for each TIC:
data TOPCOM_TIC; set Q_COMP_SHORT10_18;
keep TIC CEQQ ATQ COM_EQ;
COM_EQ = CEQQ/ATQ;
run;
proc means data=topcom_tic noprint nway;
class tic;
var com_eq;
output out=stats (where=(_stat_='MEAN'));
run;
data need;
set stats;
over_under=sign(com_eq-.5);
run;
proc freq data=need;
tables over_under;
run;
COM_EQ is a simple ratio, not a percentage.
Try changing the penultimate line from
if COM_EQ>=50 ;
to
if COM_EQ>=0.5 ;
I changed to 0.5 but I think something is incorrect with the proc means code. Any idea?
Have you inspected the data files? Are any of the values greater than 0.5?
yes, there are a few that greater than 0.5
In Q6?
the code is not running from proc means, so the ones after that show errors. Should I change it from Q6 to TOPCOM_TIC.
Thank you
What do you mean by "not running"? I.e., what is the sas log telling you? If we could see the log, we might be able to provide more effective assistance.
However, to see if I understand the object: you want to calculate for each firm (variable TIC), the average ratio of quarterly reports of common equity (CEQ) to total assets (ATQ), right? It looks to me like you are using COMPUSTAT data.
To do this you, don't need to sort - you can use the CLASS statement in proc means to get averages for each TIC:
data TOPCOM_TIC; set Q_COMP_SHORT10_18;
keep TIC CEQQ ATQ COM_EQ;
COM_EQ = CEQQ/ATQ;
run;
proc means data=topcom_tic noprint nway;
class tic;
var com_eq;
output out=stats (where=(_stat_='MEAN'));
run;
data need;
set stats;
over_under=sign(com_eq-.5);
run;
proc freq data=need;
tables over_under;
run;
Thank you
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.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.