Programming the statistical procedures from SAS

Selecting certain number of observations into a table

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 119
Accepted Solution

Selecting certain number of observations into a table

Hi

A question please, i have a table containing a large number of observations, the table ( a case-control study) looks like this

Header 1Header 2Header 4
A23

43

A86T80
A8777
A78776
A485
D2322
D771
D163
D994
C655
C5556
C77
C097

what i want is to create another table that would only include the first three observations in each group in the first columns (Header 1), here is the output

Header 1Header 2Header 4
A23

43

A86T80
A485
D2322
D771
D163
C655
C5556
C77

Any help is appreciated

er of


Accepted Solutions
Solution
‎07-05-2015 04:07 PM
Respected Advisor
Posts: 4,606

Re: Selecting certain number of observations into a table

A BY clause and a sum statement will do the trick :

data want;

set have; by Header1 notsorted;

if first.Header1 then order = 0;

order + 1;

if order <= 3;

drop order;

run;

PG

PG

View solution in original post


All Replies
Solution
‎07-05-2015 04:07 PM
Respected Advisor
Posts: 4,606

Re: Selecting certain number of observations into a table

A BY clause and a sum statement will do the trick :

data want;

set have; by Header1 notsorted;

if first.Header1 then order = 0;

order + 1;

if order <= 3;

drop order;

run;

PG

PG
Frequent Contributor
Posts: 119

Re: Selecting certain number of observations into a table

Thank you PGSats

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 206 views
  • 0 likes
  • 2 in conversation