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-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 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
  • 641 views
  • 0 likes
  • 3 in conversation