BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
gahlot1999
Fluorite | Level 6

I want to add SEQNUM variable in below dataset and I want numbering to get re-started from 1 as soon as EMPID changes....means for first 8 record SEQNUM should have normal....1, 2, 3...8 but for 9th record EMPID changed then it should have again 1, 2, etc. Like this for entire table.

Any easy way to do this.

I want to use proc sql only.

Current Dataset

gahlot1999_0-1651848289270.png

 

1 ACCEPTED SOLUTION
3 REPLIES 3
gahlot1999
Fluorite | Level 6

Can we do this same operation in proc sql step, without using data step?

Kurt_Bremser
Super User

@gahlot1999 wrote:

Can we do this same operation in proc sql step, without using data step?


Basically, no. SQL has no concept of sequence. There are methods to trick SQL into doing this, but they often rely on the use of undocumented (and therefore unreliable and dangerous) features. Apart from being (much) less performant than a data step.

Maxim 14: Use the Right Tool.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 3 replies
  • 611 views
  • 2 likes
  • 2 in conversation