BookmarkSubscribeRSS Feed
Espresso
Obsidian | Level 7

Greetings,

 

I have researched many posts regarding waterfall charts, and every example I have seen has the data vertically, meaning every observation will output to the same chart:

 

data DataDir.SJUCost;

	input Name $
		Number
		Color $;
	datalines;
	2018 755575 Red
	VFM 5628 Red
	INT 135364 Red
	OTH 3222 Red
	DFM -138900 Green
	;
run;

proc template;
	define statgraph waterfall;
		begingraph;
			layout overlay;
				waterfallchart category=name response=number / 
					colorgroup=color 
					barlabel=true
					name='waterfall' 
					dataskin=sheen 
					filltype=solid
					initialbarattrs=(color=gray4f)
					display=(connect fill outline);
			endlayout;
		endgraph;
	end;

proc sgrender template=waterfall data=DataDir.SJUCost;
	title '2018 SJU Check Cost';
run;

 

But this is not my case, in my dataset, I need the waterfall chart to take in the variables horizontally, meaning I need to output a chart for every observation on the dataset (30 obs) . Here is the same data above:

 

data DataDir.SJUCost;

	input Name $
		Number
		Color $;
	datalines;
	755575 5628 135364 3222 -138900
	;
run;

How can i process the data horizontally?

Thanks.

 

3 REPLIES 3
ballardw
Super User

If you want one chart per observation why are you doing a waterfall chart? The purpose of that type chart is partially to show the contribution to a total of each group.

 

And if by chart you actually mean one chart of one set of data then perhaps you want to use BY group processing based on something that identifies which "chart" is which. Since you would have to indicate the high and low values for each chart separately then perhaps you can provide data that would be appropriate as the bar limits from one chart are not going to carry over into a completely separate chart. At which point is sounds like you actually want a HIGHLOW plot.

 

Or can you show an example of what you want? It often takes much more than a thousand words to describe a picture...

Espresso
Obsidian | Level 7

Thanks for the reply.

OK, so I transposed the data set to, now its all vertical:

 

Capture.PNG

 

So for the data above, I need to plot only the highlighted data. One waterfall chart for col B and C, then col B and D, then Col B and E. and so forth.

Espresso
Obsidian | Level 7

Ok, back to the basic data set, where I have all waterfall data points contained in each observation, and each observation is an independent chart. Would something like this be possible, recurse over the data set and draw a waterfall chart for each?

 

data have;
	input sta $ budget $ VFM $ INT $ OTH $ DFM $;
	datalines;
	sta budget VFM INT OTH DFM
	sju 755575 5628 135364 3222 -138900
	maz 885634 4663 2522 -2525 252452
	;
run;

data _null_;
	set have;
	
	proc sgrender template=waterfall data=have;
		title '2018 SJU Check Cost';
	run;	
	
end;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 716 views
  • 0 likes
  • 2 in conversation