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 
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
  • 1625 views
  • 1 like
  • 3 in conversation