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 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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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