BookmarkSubscribeRSS Feed
Sandhyaa
Calcite | Level 5
src Colseq no
a1
a2
a3
b1
b2
c1


Based on one of the source columns, a sequence no  has to be generated. If the source value changes, then the sequene no must start from one.

Is this is possible in SAS DI without using user-written transformation?

2 REPLIES 2
LinusH
Tourmaline | Level 20

Not really, maybe by using some extensive logic using Group By and monotonic(), but that would probably be more difficult to understand, than a simple user written using by - first. logic.

Data never sleeps
Jagadishkatam
Amethyst | Level 16

Hi Sandhyaa,

I am not sure if it is possible to get the seq no as you want in DI studio without coding. May be other members can you help you if they have come across similar situation.

Here is a small piece of code which i hope can help you

data have;

     input src_col $;

datalines;

a

a

a

b

b

c

;

proc sort data=want;

    by src_col;

run;

data want;

    set have;

    retain seq_no;

    by src_col;

    if first.src_col then seq_no=1;

    else seq_no+1;

run;

Thanks,

Jagadish

Thanks,
Jag

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 790 views
  • 0 likes
  • 3 in conversation