Given this set of data, i tried using PROC Report to print all the data with a SUM of AGE(i did MEAN in the code to test between MEAN and SUM). However, when i perform, all i get is duplication of each set of data as you may see below.
Need your Kind Advice.
Below is the duplication of data which i dont want.
input
ID $ 1-14 Name $ 16-30 Sex $ 32-33 Country $ 34-45 Nationality $ 46-61 Ocupation $ 62-73 Age 75-78;
990101-14-9900 Yandhi Wong F Nigeria Nigerian Cheerleading 22
881212-10-8811 Nathan Wong M Honduras Nigerian Drug Lord 17
630303-11-6633 Dicky Wong M China Indian Monk
99 660404-14-4444 Grace Wong F Mongolia Mongolian Modeling 44
770707-07-1717 Chin Teck Min M China China Duck Shop 33
920901-09-7777 Wong Hong Qui M Malaysia Malaysian Psychologist 29
880818-10-8888 Teoh Eu Ern F Malaysia Malaysian Kungfu Master 33
A998877 Abdulla Omar F Iraq Iraqi Spy 28
proc sort data=ALFRED.shoes;
by nationality;
run;
proc report data=ALFRED.shoes
/*STYLE(HEADER)=[BACKGROUNDCOLOR=ORANGE FONT WEIGHT=BOLD*/
/*STYLE(SUMMARY)=[(COLOR=WHITE BACKGROUNDCOLOR=GREEN FONTFAMILY=ARIAL FONTSIZE=2*/
/*TEXTALIGH=CENTER CELLWIDTH=1in}*/
;
COL Name Age Country Nationality Agemean;
DEFINE Age /analysis mean;
DEFINE Country /DISPLAY 'Country of Origin';
DEFINE Agemean /COMPUTED 'Age Mean';
DEFINE Name /DISPLAY;
DEFINENationality /GROUP;
COMPUTEAgemean;
Agemean=Age.mean;
ENDCOMP;
COMPUTE Country;
IF Country = 'China' THEN
CALL DEFINE (_COL_, "STYLE", "STYLE=[COLOR=CORNFLOWERBLUE]");
ENDCOMP;
COMPUTE Age;
IF Name ='Dicky Wong' THEN CALL DEFINE (_COL_, "STYLE","STYLE=[COLOR=CHARTREUSE]");
ENDCOMP;
BREAK BEFORE Nationality/ SUMMARIZE;
/*BREAK AFTER Nationality / SUMMARIZE;*/
run;
My Result:

What do you expect ? That is what is supposed to do .
you define
BREAK BEFORE Nationality/ SUMMARIZE;
data shoes;
infile cards truncover;
input
ID : $40. Name & $30. Sex $ Country : $40. Nationality : $40. Ocupation & $40. Age ;
cards;
990101-14-9900 Yandhi Wong F Nigeria Nigerian Cheerleading 22
881212-10-8811 Nathan Wong M Honduras Nigerian Drug Lord 17
630303-11-6633 Dicky Wong M China Indian Monk 99
660404-14-4444 Grace Wong F Mongolia Mongolian Modeling 44
770707-07-1717 Chin Teck Min M China China Duck Shop 33
920901-09-7777 Wong Hong Qui M Malaysia Malaysian Psychologist 29
880818-10-8888 Teoh Eu Ern F Malaysia Malaysian Kungfu Master 33
A998877 Abdulla Omar F Iraq Iraqi Spy 28
;
run;
proc sort data=shoes;
by nationality;
run;
proc report data=shoes nowd;
COL Name Age Country Nationality Age=Agemean;
DEFINE Age /analysis sum 'Age Sum';
DEFINE Country /DISPLAY 'Country of Origin';
DEFINE Agemean/analysis mean 'Age Mean';
DEFINE Name /DISPLAY;
DEFINE Nationality /GROUP;
COMPUTE Country;
IF Country = 'China' THEN
CALL DEFINE (_COL_, "STYLE", "STYLE=[COLOR=CORNFLOWERBLUE]");
ENDCOMP;
COMPUTE Age;
IF Name ='Dicky Wong' THEN CALL DEFINE (_COL_, "STYLE","STYLE=[COLOR=CHARTREUSE]");
ENDCOMP;
BREAK BEFORE Nationality/ SUMMARIZE;
/*BREAK AFTER Nationality / SUMMARIZE;*/
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.