turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Number of observations

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-30-2017 03:46 AM

Hi everyone,

I have a dataset in which all the variables have a total observation of 68811 with there are no missing values. However, SAS uses only 68717 in regressions. Is there a way of ensuring that the number of observations equal the number of observations used in the regressions?

Thank you.

Accepted Solutions

Solution

09-30-2017
09:18 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 07:25 PM

You have 94 observations with at least one of

**nD_assets1 post nsize nlev ner ncash nGrowth nR_E nroa fic fyear sic2**

missing.

If they are all numeric vars, you can find those cases by

data suspect;

set have;

where nmiss(nD_assets1, post nsize, nlev, ner, ncash, nGrowth, nR_E, nroa, fic, fyear, sic2)>0;

run;

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 09:02 AM

Show us the sas log, which will help us help you.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 09:06 AM - edited 09-30-2017 09:08 AM

There are always one or more reasons why observations are excluded: missing values, nonpositive weights, or nonpositive frequencies. Did you look at the number of observations table? Does it agree with your assessment that there are no missing values? You can output it to a data set and print it to see additional information about why observations were excluded.

```
data class;
set sashelp.class;
if uniform(7) lt 0.1 then height = .;
if uniform(7) lt 0.1 then weight = .;
f = uniform(7) > 0.1;
w = uniform(7) > 0.1;
run;
proc print; run;
proc reg;
model weight = height;
freq f;
weight w;
ods output nobs=n;
quit;
proc print; run;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 06:54 PM

Theo_Gh wrote:

Hi everyone,

I have a dataset in which all the variables have a total observation of 68811 with there are no missing values. However, SAS uses only 68717 in regressions. Is there a way of ensuring that the number of observations equal the number of observations used in the regressions?

Thank you.

You need to post more information.

SAS uses all non-misisng by default so either you have missing or a WHERE statement or something else that's not being stated. Most likely it's the third OR option here.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

09-30-2017 07:18 PM

Sorry everyone; actually SAS does indicate that there are values. Problem is I can't identify them.

The log is provided below:

proc surveyreg data=theo.final;

3 cluster gvkey;

4 class fic fyear sic2;

5 model nD_assets1= post nsize nlev ner ncash nGrowth nR_E nroa fic fyear sic2/solution ADJRSQ;

6 run;

NOTE: Writing HTML Body file: sashtml.htm

NOTE: In data set FINAL, total 68811 observations read, 94 observations with missing values are

omitted.

NOTE: PROCEDURE SURVEYREG used (Total process time):

real time 8.16 seconds

cpu time 2.96 seconds

Solution

09-30-2017
09:18 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 07:25 PM

You have 94 observations with at least one of

**nD_assets1 post nsize nlev ner ncash nGrowth nR_E nroa fic fyear sic2**

missing.

If they are all numeric vars, you can find those cases by

data suspect;

set have;

where nmiss(nD_assets1, post nsize, nlev, ner, ncash, nGrowth, nR_E, nroa, fic, fyear, sic2)>0;

run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mkeintz

09-30-2017 07:48 PM

data theo.new;

set theo.final;

where nmiss(nD_assets1, post nsize, nlev, ner, ncash, nGrowth, nR_E, nroa)>0;

run;

I used the code above but I'm getting a syntax error

set theo.final;

where nmiss(nD_assets1, post nsize, nlev, ner, ncash, nGrowth, nR_E, nroa)>0;

run;

I used the code above but I'm getting a syntax error

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 07:54 PM

put a comma between all of your variables (or use OF as I did then you don't need any commas).

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 07:26 PM

data ...;

set ...;

if nmiss(of ... all analysis variables variable list...);

run;

proc print; run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to WarrenKuhfeld

09-30-2017 08:17 PM

Please bear with me.

The codes works now.I get a new dataset but when I use the new dataset in a regression, I get an error that there are no observations in the dataset even though there are

The codes works now.I get a new dataset but when I use the new dataset in a regression, I get an error that there are no observations in the dataset even though there are

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Theo_Gh

09-30-2017 08:22 PM

You asked how to find out how to identify the observations with missing values. That is what I showed you. You can't analyze that data set. Analyze the original data set.