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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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