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
- /
- Is there a way to have a row zero?

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-29-2016 08:51 AM

Hi,

I was wondering if it is possible to have a row zero, that will not be counted in an analyis, but would contain, important information.

Best,

Accepted Solutions

Solution

08-31-2016
10:27 AM

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

Posted in reply to drichmo1

08-29-2016 02:12 PM

I would ask what you are doing that this is causin issues but the OBS number is not in the data set. So add a variable with the value you want:

Data work.one4;

set work.one3;

Obs = _n_ -1;

run;

All Replies

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

Posted in reply to drichmo1

08-29-2016 09:06 AM

To store important information about the table within the table itself, look at column and dataset labels.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

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

Posted in reply to KurtBremser

08-29-2016 09:12 AM

Well, the information I am storing tells the total amount of row entries divided by 3 for each row, in order to find a solution for the total amount of moves needed for a puzzel. In this case it will not be a label, however it will indicate how far you are from the solution.

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

Posted in reply to drichmo1

08-29-2016 09:18 AM

The number of observations in a dataset can either be read from sashelp.vtable (dictionary.tables in PROC SQL), or you can use the nobs= option in the set statement to create a data step variable that holds that value.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

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

Posted in reply to drichmo1

08-29-2016 10:03 AM

Wouldn't that be a column? Please post sample input and desire output.

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

Posted in reply to Reeza

08-29-2016 10:50 AM

Here is my output. To rephrase my question: Is there a way to make an observation 0. I want obersevation 1 to be 0.

Solution

08-31-2016
10:27 AM

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

Posted in reply to drichmo1

08-29-2016 02:12 PM

I would ask what you are doing that this is causin issues but the OBS number is not in the data set. So add a variable with the value you want:

Data work.one4;

set work.one3;

Obs = _n_ -1;

run;

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

Posted in reply to drichmo1

08-30-2016 02:34 AM

There.is.no.observation.zero.in.a.SAS.dataset. Never.

You only can do that:

```
data want;
set have;
retain counter;
if _n_ = 1
then do;
counter = 1;
output;
counter = 0;
* set values for your "0" observation;
output;
counter = 1;
end;
else do;
counter + 1;
output;
end;
run;
proc sort data=want;
by counter;
run;
```

This creates a virtual obs 0, but be aware that any sort other than by counter will move that "zero obs" to another place.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

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

Posted in reply to drichmo1

08-29-2016 11:28 PM

Check WEIGHT statement. if you are using proc freq , check ZEROS option of WEIGHT.