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?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 302 views
  • 1 like
  • 2 in conversation