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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1140 views
  • 0 likes
  • 2 in conversation