DATA Step, Macro, Functions and more

PROC PRINT and titles

Reply
Occasional Contributor
Posts: 9

PROC PRINT and titles

one

x   y   z

1  A  27

1  A  33

1  B  45

2  A  52

2  B  69

3  B  70

4  A  82

4  C  91

 

data two ;

set one;

by x y;

if first.y;

run;

 

proc print data = two noobs;

run;

 

can somebody plz explain exactly what we are doing in this program and why i m getting this output 

 

x  y  z

1 A  27

1 B  45

2 A  52

2 B  69

3 B  70

4 A  82

4 C  91

Occasional Contributor
Posts: 17

Re: PROC PRINT and titles

Not exactly sure what you want to have, but you are outputting the first record in var "y"

 

Super User
Posts: 13,579

Re: PROC PRINT and titles


@sanyam13 wrote:

one

x   y   z

1  A  27

1  A  33

1  B  45

2  A  52

2  B  69

3  B  70

4  A  82

4  C  91

 

data two ;

set one;

by x y;

if first.y;

run;

 

proc print data = two noobs;

run;

 

can somebody plz explain exactly what we are doing in this program and why i m getting this output 

 

x  y  z

1 A  27

1 B  45

2 A  52

2 B  69

3 B  70

4 A  82

4 C  91


The "If first.y;" statement says to keep the record only for the first of each group of y values for each X group.

Note that the 1 A 33 is not in the output as it is the second value of A for variable Y where X is 1.

Ask a Question
Discussion stats
  • 2 replies
  • 44 views
  • 1 like
  • 3 in conversation