Hi I have a problem creating a graph in SAS. my data is as follow: Date, comp_1,comp_2, comp_3, total_value. My data is sorted by dates. the variable comp_ represent the value of the company at a specific data. This is my code at the moment:
proc gplot data=dev2.Actionfinal2;
plot (comp_1 comp_2 comp_3)*date
/ overlay areas=3 vaxis=0 to 100000 by 20000;
symbol1 i=join v= cv= ci=red;
symbol2 i=join v= cv= ci=blue;
symbol3 i=join v= cv= ci=green;
run;
quit;
This graph show me the 3 companies value overlayed, but I want them stacked so I can see the total value of the companies for each dates. Do I need to reformat my data, what option can I use ?
You will need to create a new variable with the aggregated value of your three "comp" variables. See this SAS usage note with a great example. That should get you started and welcome to StackOverflow!
UPDATE: I think I better understand the problem: you need to denormalize your data (turn the columns into observations). So try this:
data test(keep=company value date);
set dev2.Actionfinal2;
company = 1; value = comp_1; output;
company = 2; value = comp_2; output;
company = 3; value = comp_3; output;
run;
proc sort data=test;
by date company;
run;
data test2;
set test;
by date;
if first.date then new_y=0;
new_y + value;
run;
symbol1 i=join v= cv= ci=red;
symbol2 i=join v= cv= ci=blue;
symbol3 i=join v= cv= ci=green;
proc gplot data=test2;
plot new_y*date=company
/ areas=3 vaxis=0 to 100000 by 20000;
run;
quit;