BookmarkSubscribeRSS Feed
deleted_user
Not applicable
How do i assign a number sequence by observation?

If there are unequal number of observations from subjects:

Subject Observation Sequence
A XY 1
A AB 2
A ZW 3
B XY 1
C AB 1
C HG 2

How do i create the Sequence column such that it is of running sequence by subject?
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
One option is to assign a SAS numeric variable and after sorting your file with PROC SORT and using a specific BY variable list, use a DATA step to assign the numeric sequence variable. You will need to look at using a BY statement in the DATA step and using IF FIRST. to reset your sequence variable as needed.

Suggest you search the SAS support http://support.sas.com/ website for DOC and supplemental technical reference and conference papers on the topic -- here is a Google advanced search argument to consider using:

first last by group processing site:sas.com


Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 853 views
  • 0 likes
  • 2 in conversation