BookmarkSubscribeRSS Feed
Sandhyaa
Calcite | Level 5


we have a requirement like this.

src

src col1src col2src col3
aa1a123a234
bb1b123b234b345

tgt

tgt col1tgt col2tgt col3.1tgt col3.2
aa11a123
aa12a234
bb11b123
bb12b234
bb13b345

We need to split the src_col3 into multiple rows such that in each row, the tgt_col3.2 will have only 4 characters. The no. of rows that can result from a single row is dynamic as it is based on the data length of the src_col3. tgt_col3.1 is a sequnece no whcih denotes, for each tgt_col1 ie."a", how many rows are made up.

Can this be achieved using SAS DI with any transformation?

4 REPLIES 4
LinusH
Tourmaline | Level 20

Looks like a job for a data step within a User Written Code transformation.

The code will be as dynamic as you write it, using the transformations dynamic macro variables as much as possible.

Data never sleeps
Sandhyaa
Calcite | Level 5

so, cant we achieve this without going for an user written transformation?

LinusH
Tourmaline | Level 20

Not really.

The standard transformation scenario could be:

  • On extract transform for each position interval that you can possibly have (depending on the maximum length of src_col3).
  • Append the results

So it wouldn't be very dynamic...

Data never sleeps
LinusH
Tourmaline | Level 20

Another option would be to:

  • Use Extract to split the src_col3 into all necessary columns (depending on the maximum length of src_col3)
  • Try to master the Transpose transformation to generate for each new src_col3 column.
Data never sleeps

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