SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

sequence no based on an input field

Reply
Contributor
Posts: 23

sequence no based on an input field

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?

Super User
Posts: 5,254

Re: sequence no based on an input field

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
Trusted Advisor
Posts: 1,128

Re: sequence no based on an input field

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
Ask a Question
Discussion stats
  • 2 replies
  • 177 views
  • 0 likes
  • 3 in conversation