BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

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.

PROC REport problemjpg.jpg

 

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:
PROC REport problemjpg.jpg

 

1 REPLY 1
Ksharp
Super User

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;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 824 views
  • 0 likes
  • 2 in conversation