BookmarkSubscribeRSS Feed
VVDR
Obsidian | Level 7

Hi all,

I am using SAS DI user written transformation and I have the following doubts. Please suggest to gain some knowledge.

I am using an existing user written transformation. 

In that transformation, in the existing Data step block I am manually writing a code and creating one new column X. 

That column loads the data into the next level crated table ABC.

what all steps I need to run in terms of executing it successfully.

1. In the mapping section, do I need to right click --> and create a new column X. 

2. Map it to the ABC column manually as X is an existing column already.

 

I am very much interested in this topic here. Please help me in understanding if it is correct way of dealing while creating a new column. 

5 REPLIES 5
Patrick
Opal | Level 21

@VVDR 

You can do whatever you like with user written code so it's sort of hard to answer your question. 

If you don't use any of the metadata based macro variables that DIS generates in your user written code then the code won't depend on anything you do in SAS Metadata. In such a case you just want to have a target metadata table that's in sync with the physical table that your user written code generates. 

It still doesn't hurt if you do the source to target mapping - not because this will affect what gets executed but because it will support metadata based lineage and impact analysis.

I personally would as a bare minimum at least use the DIS generated macro variables for the source and target tables in your user written code (&_input, &_output). Have a look into the code tab and you'll see what gets generated and is available.

 

VVDR
Obsidian | Level 7

The other way of asking this question-- Can the user written transformation generate a new column so that it can be mapped to the target table columns.

Please advise.

Regards

Rams129

 

LinusH
Tourmaline | Level 20

Quick answer - no.

 

The main difference between User Written code and User Written transformation is that the later logic can be reused. There is no automatic populaitn of tnew arget column names.

Data never sleeps
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @VVDR 

 

I always do the following:

 

  1. Write the code using &_INPUT and &_OUTPUT as data set names in the code.
  2. Update the output table's metadata after succesful execution.
  3. Fix the mappings to secure lineage and column impact analysis.

Tip:

A user written transformation often do complicated tings (otherwise a standard transformation is preferred), so a new output variable is a result of operations on several input columns. You cannot map more than one input column to an output column, but it can be solved with an expression on the output column like %dummy(inputcol1,inputcol2,inputcol3). The macro is never executed and is just a way of forcing mapping n:1,  so there is no need for an actual %dummy macro in a macro library.

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @VVDR 

 

Tips continued:

 

All permanent tables read or written by the transformation code should be on the canvas and connected to the transformation. Otherwise the lineage is lost. 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 948 views
  • 1 like
  • 4 in conversation