BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

I have the below dataset

 

data A;
Input CHANNEL $ AMOUNT ;
cards;
ABC 110
ABC 220
ABC 770
BBC 810
BBC 190
;
run;

 

May I know how to generate the below output with the above data? Thanks.

 

Channel  Amount  Percent
ABC        110         0.1
ABC         220        0.2
ABC         770        0.7
BBC         110        0.11
BBC          890       0.89
5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Proc means/summary/freq.  Simple search on the SAS docs gives examples:

http://support.sas.com/kb/25/237.html

DJongman
Obsidian | Level 7

Hi scb,

 

As RW9 already stated in his post see the example link he provided.

But hereby a little bit of code to get you started:

 

Data A;
Input Channel $ Amount ;
cards;
ABC 110
ABC 220
ABC 770
BBC 810
BBC 190
;
run;

Proc SQL;                                                       
  Create Table B AS                                     
    Select *,(Amount/SUM(Amount)) AS Percent format=6.2      
  	From A                                             
	Group BY Channel;
Quit;

 

Ksharp
Super User
data A;
Input CHANNEL $ AMOUNT ;
cards;
ABC 110
ABC 220
ABC 770
BBC 810
BBC 190
;
run;

proc sql;
select *,AMOUNT/sum(AMOUNT)  format=percent8.2
 from a as x
   group by CHANNEL;
quit;
acordes
Rhodochrosite | Level 12
data A;
Input CHANNEL $ AMOUNT ;
cards;
ABC 110
ABC 220
ABC 770
BBC 810
BBC 190
;
run;

DATA A2;
SET A;
CHAR_AMOUNT=AMOUNT;
RUN;

PROC FORMAT;
PICTURE PCTPIC low-high='000.0%';
RUN;


TITLE;
PROC TABULATE DATA=WORK.A2 OUT=TEST ;
CLASS CHANNEL CHAR_AMOUNT;
KEYLABEL PCTSUM="% within Channel";
VAR amount;
TABLE CHANNEL*CHAR_AMOUNT, (amount*(SUM*F=6. PCTSUM<AMOUNT*CHAR_AMOUNT>*F=PCTPIC.)) / RTS=20;
RUN;
sasuser123123
Quartz | Level 8
And I've doubt ...
I've two variables TRT1,TRT2 those has values like 45(23%),55(56%) I want to add new variable total which should contains count and percentage like 100(79)... Can you please tell me how to create

sas-innovate-white.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.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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
  • 5 replies
  • 24360 views
  • 1 like
  • 6 in conversation