BookmarkSubscribeRSS Feed
melhaf
Fluorite | Level 6

Hi,


If my dataset looks like this, what would be my category data for this?  (this is just fiction)

 

Capture.JPG

 

I want to have (I have two dataset, I want to compare two periods)  stacked columns diagram and I'm using this code:

/* Merge the calculated datasets for each period */
data merged_data;
merge calc_period1 (rename=(ECL_stage1=ECL_stage1_1 ECL_stage2=ECL_stage2_1 ECL_stage3=ECL_stage3_1))
calc_period2 (rename=(ECL_stage1=ECL_stage1_2 ECL_stage2=ECL_stage2_2 ECL_stage3=ECL_stage3_2));
run;

 

/* Stacked column chart */
proc sgplot data=merged_data;
vbar category / response=ECL_stage1_1 group=period1 groupdisplay=stacked barwidth=0.4;
vbar category / response=ECL_stage2_1 group=period1 groupdisplay=stacked barwidth=0.4;
vbar category / response=ECL_stage3_1 group=period1 groupdisplay=stacked barwidth=0.4;

vbar category / response=ECL_stage1_2 group=period2 groupdisplay=stacked barwidth=0.4 barattrs=(color=lightgray);
vbar category / response=ECL_stage2_2 group=period2 groupdisplay=stacked barwidth=0.4 barattrs=(color=lightgray);
vbar category / response=ECL_stage3_2 group=period2 groupdisplay=stacked barwidth=0.4 barattrs=(color=lightgray);

yaxis label="ECL (in millions)";
xaxis discreteorder=data;
keylegend / location=inside position=topright across=1;
run;

 

but I don't know what what my category variable would be.

 

1 REPLY 1
melhaf
Fluorite | Level 6

I don't know how to edit my thread, but the whole looks like this

 
proc sql;
    create table calc_period1 as select 
        ('EAD [EUR]'n * 'PD [%]'n * 'LGD [%]'n) / 1000000 as ECL_stage1,
        ('EAD [EUR]'n * 'LTPD [%]'n * 'LGD [%]'n) / 1000000 as ECL_stage2,
        ('EAD [EUR]'n * 'LGD [%]'n) / 1000000 as ECL_stage3
    from period1;
quit;
 
proc sql;
    create table calc_period2 as select 
        ('EAD [EUR]'n * 'PD [%]'n * 'LGD [%]'n) / 1000000 as ECL_stage1,
        ('EAD [EUR]'n * 'LTPD [%]'n * 'LGD [%]'n) / 1000000 as ECL_stage2,
        ('EAD [EUR]'n * 'LGD [%]'n) / 1000000 as ECL_stage3
from period2;
quit;

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 295 views
  • 0 likes
  • 1 in conversation