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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 561 views
  • 1 like
  • 2 in conversation