BookmarkSubscribeRSS Feed
Sean_OConnor
Fluorite | Level 6

Folks,

 

I'm having an issue with something at the moment which I'd be grateful for some assistance on.  

 

I've a dataset at the moment which has a number of 0 for variable occurrence.

 

What I would like to do is change where there is a 0 to 1 and subsequently change the 1 to 2 and so on. Below gives a better idea.

 

Data in current format;

 

IDOccurrenceValue
63045
63165
63298
221100
231125
241130
251130
45196
45288
45344

 

What I would like to occur;

 

IDOccurrenceValue
63145
63265
63398
221100
231125
241130
251130
45196
45288
45344
1 REPLY 1
Astounding
PROC Star

If there is an instance of occurrence=0, will it always be for the first observation for an ID?

 

Here's an approach that makes a reasonable guess about how to handle that question:

 

data want;

set have;

by ID;

if first.ID then increment=0;

retain increment;

if occurrence=0 then increment=1;

occurrence = occurrence + increment;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 632 views
  • 0 likes
  • 2 in conversation