BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
drichmo1
Fluorite | Level 6

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, 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

View solution in original post

8 REPLIES 8
drichmo1
Fluorite | Level 6

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. 

Kurt_Bremser
Super User

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.

Reeza
Super User

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

drichmo1
Fluorite | Level 6

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


Screen Shot 2016-08-26 at 10.23.05 PM.png
ballardw
Super User

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;

Kurt_Bremser
Super User

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.

Ksharp
Super User
Check WEIGHT statement.


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


sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1387 views
  • 0 likes
  • 5 in conversation