## Find two central observation of SAS data set.

Solved
Occasional Contributor
Posts: 12

# Find two central observation of SAS data set.

[ Edited ]

I have to find  two central observations of a one character variable dataset. It has even number of observation.

dataset is :

data dset;
infile datalines ;
input sex \$ ;
datalines;
M
M
F
F
F
F
M
M
F
F
F
F
F
F
F
M
M
F
F
F
F
F
M
M
;
run;

Accepted Solutions
Solution
‎11-15-2016 12:29 PM
PROC Star
Posts: 1,283

## Re: Find two central observation of SAS data set.

try this

``````data want;
set dset nobs=nobs;
if _N_ = nobs/2 or _N_ = nobs/2 + 1;
run;``````

All Replies
Solution
‎11-15-2016 12:29 PM
PROC Star
Posts: 1,283

## Re: Find two central observation of SAS data set.

try this

``````data want;
set dset nobs=nobs;
if _N_ = nobs/2 or _N_ = nobs/2 + 1;
run;``````
PROC Star
Posts: 1,283

## Re: Find two central observation of SAS data set.

I have assumed that you always have an equal number of observations in your dataset

Occasional Contributor
Posts: 12

## Re: Find two central observation of SAS data set.

It works Thank you.
☑ This topic is solved.

Discussion stats
• 3 replies
• 327 views
• 1 like
• 2 in conversation