BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DME790
Pyrite | Level 9

Hi All,

 

I need to calculate the percentage of each an observation within that variable.

 

I have this cade at the moment

 

 


data test;
	Input QUEUE_CD $ Bay Network;
	Datalines;
ABS 1 22949
ACD 1 3767
ACE 2 967
ACR 18 20513
ADV 5 92382
ALD 1 1764
ALE 17 13243
ALY 2 5128
CCB 1 25006
CHK 3295 25129

;
Run;


Proc Report data=test;
	Column queue_cd Bay Network BayPercent;
	Define Queue_CD / Display 'Queue';
		Define Bay / Display 'Baylink' Analysis sum f=comma9.;
		Define Network / Display 'Network' Analysis sum f=comma9.0;
		Define BayPercent / Computed 'Bay Percent of Network' f=percent9.2;
			Compute BayPercent;
				BayPercent = Bay.sum / Network.sum;
					Endcomp;
		Rbreak after / summarize;
RUN;  

which gives me the output of                                   Need to add the Bay Percent into the Proc Report

 

Bay1.GIFBay2.GIF

 

Any help appreciated.

 

Cheers

 

Dean

 

1 ACCEPTED SOLUTION

Accepted Solutions
RM6
Obsidian | Level 7 RM6
Obsidian | Level 7

a compute block to get the total of bay before all the computation will suffice


Proc Report data=test;
	Column queue_cd Bay BayPct Network BayPercent;
	Define Queue_CD / Display 'Queue';
		Define Bay / Display 'Baylink' Analysis sum f=comma9.;
		Define BayPct / Computed 'Bay Percent' f=percent9.2;
		Define Network / Display 'Network' Analysis sum f=comma9.0;
		Define BayPercent / Computed 'Bay Percent of Network' f=percent9.2;
			
			 compute  before; 
				 Bay_tot = Bay.sum; 
				 endcomp;

			Compute BayPct;
				BayPct = Bay.sum / Bay_tot;
					Endcomp;
			Compute BayPercent;
				BayPercent = Bay.sum / Network.sum;
					Endcomp;
		Rbreak after / summarize;
RUN;  

View solution in original post

2 REPLIES 2
RM6
Obsidian | Level 7 RM6
Obsidian | Level 7

a compute block to get the total of bay before all the computation will suffice


Proc Report data=test;
	Column queue_cd Bay BayPct Network BayPercent;
	Define Queue_CD / Display 'Queue';
		Define Bay / Display 'Baylink' Analysis sum f=comma9.;
		Define BayPct / Computed 'Bay Percent' f=percent9.2;
		Define Network / Display 'Network' Analysis sum f=comma9.0;
		Define BayPercent / Computed 'Bay Percent of Network' f=percent9.2;
			
			 compute  before; 
				 Bay_tot = Bay.sum; 
				 endcomp;

			Compute BayPct;
				BayPct = Bay.sum / Bay_tot;
					Endcomp;
			Compute BayPercent;
				BayPercent = Bay.sum / Network.sum;
					Endcomp;
		Rbreak after / summarize;
RUN;  
Ksharp
Super User

data test;
	Input QUEUE_CD $ Bay Network;
	Datalines;
ABS 1 22949
ACD 1 3767
ACE 2 967
ACR 18 20513
ADV 5 92382
ALD 1 1764
ALE 17 13243
ALY 2 5128
CCB 1 25006
CHK 3295 25129

;
Run;


Proc Report data=test nowd;
	Column queue_cd Bay Bay_Percent Network BayPercent;
	Define Queue_CD / Display 'Queue';
		Define Bay / Display 'Baylink' Analysis sum f=comma9.;
		Define Bay_Percent / Computed 'Bay Percent' f=percent9.2;

		Define Network / Display 'Network' Analysis sum f=comma9.0;
		Define BayPercent / Computed 'Bay Percent of Network' f=percent9.2;
			Compute BayPercent;
				BayPercent = Bay.sum / Network.sum;
			Endcomp;

			compute before;
             sum=bay.sum;
			endcomp;
			Compute Bay_Percent;
				Bay_Percent = Bay.sum / sum;
			Endcomp;

		Rbreak after / summarize;
RUN;  

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 755 views
  • 1 like
  • 3 in conversation