Hi
A question please, i have a table containing a large number of observations, the table ( a case-control study) looks like this
Header 1 | Header 2 | Header 4 |
---|---|---|
A | 23 | 43 |
A | 86T | 80 |
A | 87 | 77 |
A | 78 | 776 |
A | 48 | 5 |
D | 23 | 22 |
D | 77 | 1 |
D | 16 | 3 |
D | 99 | 4 |
C | 65 | 5 |
C | 555 | 6 |
C | 7 | 7 |
C | 09 | 7 |
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 1 | Header 2 | Header 4 |
---|---|---|
A | 23 | 43 |
A | 86T | 80 |
A | 48 | 5 |
D | 23 | 22 |
D | 77 | 1 |
D | 16 | 3 |
C | 65 | 5 |
C | 555 | 6 |
C | 7 | 7 |
Any help is appreciated
er of
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
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
Thank you PGSats
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.