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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.