Help using Base SAS procedures

Getting duplication of each records when doing PROC Report

Reply
Contributor
Posts: 70

Getting duplication of each records when doing PROC Report

[ Edited ]

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

 

Super User
Posts: 9,681

Re: Getting duplication of each records when doing PROC Report

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;
Ask a Question
Discussion stats
  • 1 reply
  • 217 views
  • 0 likes
  • 2 in conversation