BookmarkSubscribeRSS Feed
lisa2002
Fluorite | Level 6

Hello everyone, 

 

I'm new to SAS and I need some assistance.  I have to create a counter variable to count the number of observations in the dataset

 

status  Cause of Death    sex

dead         other               female

dead                                female

alive        cancer              male

alive         other               male

 

These are some of the columns in my dataset.  There is 18 columns total maybe I am a bit confused on what a counter variable is please provide some assistance.  

 

I found this example... am I headed the right way??

data want;
set help;
by id;
if first.id then seq=0;
seq+1;
run;

 

Thanks everyone!

 

 

1 REPLY 1
ballardw
Super User

@lisa2002 wrote:

Hello everyone, 

 

I'm new to SAS and I need some assistance.  I have to create a counter variable to count the number of observations in the dataset

 

status  Cause of Death    sex

dead         other               female

dead                                female

alive        cancer              male

alive         other               male

 

These are some of the columns in my dataset.  There is 18 columns total maybe I am a bit confused on what a counter variable is please provide some assistance.  

 

I found this example... am I headed the right way??

 


It depends on what you want.

Number of observations total in the data set?

Or of specific values in the data set?

Do you need a data set (something processed by another program or steps) or a report (people read these)?

 

Proc contents will report on the total number of observations in the data set.

Proc freq will count number of observations with each value and number missing.

 

Can you show a small example of the data at start and what the result should be?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 321 views
  • 1 like
  • 2 in conversation