BookmarkSubscribeRSS Feed
Emma8
Quartz | Level 8
 
5 REPLIES 5
PGStats
Opal | Level 21

Please explain the value "1_0" in the second observation in more detail.

 

 

PG
Emma8
Quartz | Level 8
 
PGStats
Opal | Level 21

OK, and what is the zero?

PG
PeterClemmensen
Tourmaline | Level 20
I still don’t follow. Please explain further.
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input ID $ Number;
datalines;
A 1  
A 2  
A 5  
A 19 
A 19 
B 1  
B 3  
;

data want;
   set have;
   by ID;
   if dif(Number) not in (0, 1) then numberoftimes + 1;
   if first.ID then numberoftimes = 0;
run;

 

 

Result:

 

ID  Number  numberoftimes 
A   1       0 
A   2       0 
A   5       1 
A   19      2 
A   19      2 
B   1       0 
B   3       1 

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

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1690 views
  • 1 like
  • 3 in conversation