BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidCaliman
Calcite | Level 5

Is possible, using only transformations in DI Studio (without using programming), get the previous record of a data set and implement the logic below?

Input:

1 a

1 b

1 c

2 d

3 e

3 f

Output:

I need to calculate a new column that uses the value from the previous record.

1 a   a

1 b   a-b

1 c   a-b-c

2 d   d

3 e   e

3 f   e-f

1 ACCEPTED SOLUTION

Accepted Solutions
DavidCaliman
Calcite | Level 5

I found the answer to this problem on the link below.

I added code in the user written code transformation and it worked.

Thank you.

https://communities.sas.com/message/53141

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

From your sample (which seems  abit inconsistent), I would say no.

If this is a common task, you could package your logic in a  User Written Transformation so it could be reused.

But can I question the purpose for this logic? From the little information you give, the calculation doesn't look like anything that needs to be stored in a Data Warehouse process, rather a customized report. Please tell us more about the business requirement for this calculation.

Data never sleeps
DavidCaliman
Calcite | Level 5

I need the following final result:

Input:

cd dsc

1 a

1 b

1 c

2 d

3 e

3 f

Output:

I need to group by code and do a concatenation descriptions.

cd concat

1 a-b-c

2 d

3 e-f

LinusH
Tourmaline | Level 20

Ok, but I still miss the business requirement, and how do you define the rule which values you need to concatenate?

Data never sleeps
DavidCaliman
Calcite | Level 5

I found the answer to this problem on the link below.

I added code in the user written code transformation and it worked.

Thank you.

https://communities.sas.com/message/53141

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 4 replies
  • 1562 views
  • 0 likes
  • 2 in conversation