I have a big database, with the variables: leaf, lgd, in_default.
I need a table of frequencies that give the average lgd per sheet na in_default.
And also the total percentage of dissipation per sheet.
I need it, for example:
LEAF | IN_DEFAULT=0 | IN_DEFAULT=0 | ALL IN_DEFAULT | PERCENT | MEAN(LGD) | |
1 | 2 | 0 | 2 | 22% | 0,33 | |
2 | 1 | 2 | 3 | 33% | 0,25 | |
3 | 2 | 2 | 4 | 45% | 0,325 | |
ALL | 5 | 4 | 9 |
DATABASE I HAVE:
LEAF | LGD | IN_DEFAULT |
1 | 0,15 | 0 |
2 | 0,25 | 1 |
3 | 0,35 | 1 |
3 | 0,23 | 0 |
2 | 0,27 | 1 |
3 | 0,31 | 1 |
3 | 0,41 | 0 |
2 | 0,22 | 0 |
1 | 0,51 | 0 |
Have you tried PROC TABULATE?
data have;
infile cards dsd truncover;
input LEAF LGD IN_DEFAULT;
cards;
1, 0.15, 0
2, 0.25, 1
3, 0.35, 1
3, 0.23, 0
2, 0.27, 1
3, 0.31, 1
3, 0.41, 0
2, 0.22, 0
1, 0.51, 0
;;;;
proc tabulate data=have;
class leaf in_default;
var LGD;
table (leaf all), (in_default All)*N PCTN LGD*Mean;
run;
@Thalitacosta wrote:
I have a big database, with the variables: leaf, lgd, in_default.
I need a table of frequencies that give the average lgd per sheet na in_default.
And also the total percentage of dissipation per sheet.
I need it, for example:
LEAF IN_DEFAULT=0 IN_DEFAULT=0 ALL IN_DEFAULT PERCENT MEAN(LGD) 1 2 0 2 22% 0,33 2 1 2 3 33% 0,25 3 2 2 4 45% 0,325 ALL 5 4 9
DATABASE I HAVE:
LEAF LGD IN_DEFAULT 1 0,15 0 2 0,25 1 3 0,35 1 3 0,23 0 2 0,27 1 3 0,31 1 3 0,41 0 2 0,22 0 1 0,51 0
Have you tried PROC TABULATE?
data have;
infile cards dsd truncover;
input LEAF LGD IN_DEFAULT;
cards;
1, 0.15, 0
2, 0.25, 1
3, 0.35, 1
3, 0.23, 0
2, 0.27, 1
3, 0.31, 1
3, 0.41, 0
2, 0.22, 0
1, 0.51, 0
;;;;
proc tabulate data=have;
class leaf in_default;
var LGD;
table (leaf all), (in_default All)*N PCTN LGD*Mean;
run;
@Thalitacosta wrote:
I have a big database, with the variables: leaf, lgd, in_default.
I need a table of frequencies that give the average lgd per sheet na in_default.
And also the total percentage of dissipation per sheet.
I need it, for example:
LEAF IN_DEFAULT=0 IN_DEFAULT=0 ALL IN_DEFAULT PERCENT MEAN(LGD) 1 2 0 2 22% 0,33 2 1 2 3 33% 0,25 3 2 2 4 45% 0,325 ALL 5 4 9
DATABASE I HAVE:
LEAF LGD IN_DEFAULT 1 0,15 0 2 0,25 1 3 0,35 1 3 0,23 0 2 0,27 1 3 0,31 1 3 0,41 0 2 0,22 0 1 0,51 0
@Thalitacosta wrote:
I have a big database, with the variables: leaf, lgd, in_default.
I need a table of frequencies that give the average lgd per sheet na in_default.
And also the total percentage of dissipation per sheet.
I need it, for example:
LEAF IN_DEFAULT=0 IN_DEFAULT=0 ALL IN_DEFAULT PERCENT MEAN(LGD) 1 2 0 2 22% 0,33 2 1 2 3 33% 0,25 3 2 2 4 45% 0,325 ALL 5 4 9
DATABASE I HAVE:
LEAF LGD IN_DEFAULT 1 0,15 0 2 0,25 1 3 0,35 1 3 0,23 0 2 0,27 1 3 0,31 1 3 0,41 0 2 0,22 0 1 0,51 0
Please look very closely at your "need" table. You have two columns with the same heading "IN_DEFAULT=0" without telling us what the numeric value below either one comes from. Where does the value from "ALL IN_DEFAULT" come from? And for the Percent numerator and denominator come from: not just variables but the numbers that would generate those
data have;
infile cards dsd truncover;
input LEAF LGD IN_DEFAULT;
cards;
1, 0.15, 0
2, 0.25, 1
3, 0.35, 1
3, 0.23, 0
2, 0.27, 1
3, 0.31, 1
3, 0.41, 0
2, 0.22, 0
1, 0.51, 0
;;;;
proc sql;
create table want as
select put(leaf,best32. -l) as leaf,
sum(IN_DEFAULT=0) as a label='IN_DEFAULT=0',sum(IN_DEFAULT=1) as b label='IN_DEFAULT=1',
count(*) as n label='ALL IN_DEFAULT',
calculated n/(select count(*) from have) as per format=percent8.2 label='PERCENT',
mean(LGD) as mean label='MEAN(LGD)' format=commax12.2
from have
group by leaf
union all
select 'ALL',sum(IN_DEFAULT=0),sum(IN_DEFAULT=1),count(*),.,. from have
;
quit;
proc print label noobs;run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.