src Col | seq no |
---|---|
a | 1 |
a | 2 |
a | 3 |
b | 1 |
b | 2 |
c | 1 |
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?
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.
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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.