Hi,
I am trying to generate SAS DI jobs because they are processed in an external tool, but I want to see the complete data lineage in SAS.
So, the current situation is: Staging => Data Vault => Logic Data Model => Data Marts
All but staging to data vault is built in SAS DI Studio. I want to create "dummy" job to generate data lineage from data vault to staging.
This is my code so far:
DATA work.kip ;
LENGTH uri_job uri_TA uri_TS uri_CM uri_TXT uri_CO $64. ;
* Create new objects ;
rc = metadata_newobj('Job', uri_job, '_Voorbeeldje', 'Foundation') ;
rc = metadata_newobj('TransformationActivity', uri_TA, 'TransKip', 'Foundation') ;
rc = metadata_newobj('TransformationStep', uri_TS, 'User Written', 'Foundation') ;
rc = metadata_newobj('ClassifierMap', uri_CM, 'UserWrittenKip', 'Foundation') ;
rc = metadata_newobj('TextStore', uri_TXT, 'TextStoreKip', 'Foundation') ;
rc = metadata_newobj('CustomAssociation', uri_CO, 'ControlOrder', uri_job, 'CustomAssociations') ;
* Set attributes ;
rc = metadata_setattr(uri_job, 'UsageVersion', '1000000') ;
rc = metadata_setattr(uri_job, 'PublicType', 'Job') ;
* Locatie toevoegen ;
* MyFolder: A5NKZYZ3.AA0000CA ;
rc = metadata_setassn(uri_job, 'Trees', 'Append', 'omsobj:Tree/A5NKZYZ3.AA0000CA') ;
* AssociatedObjects toevoegen ;
rc = metadata_setassn(uri_job, 'AssociatedObjects', 'Append', uri_TS) ;
* TransformationActivity toevoegen ;
rc = metadata_setassn(uri_job, 'JobActivities', 'Append', uri_TA) ;
* Tabellen toevoegen ;
* Test_Class: A5NKZYZ3.BH0004QE ;
* Test_ClassFit: A5NKZYZ3.BH0004QF ;
rc = metadata_setassn(uri_TA, 'TransformationTargets', 'Append', 'omsobj:PhysicalTable/A5NKZYZ3.BH0004QE') ;
rc = metadata_setassn(uri_TA, 'TransformationTargets', 'Append', 'omsobj:PhysicalTable/A5NKZYZ3.BH0004QF') ;
* TransformationStep toevoegen ;
rc = metadata_setassn(uri_TA, 'Steps', 'Append', uri_TS) ;
rc = metadata_setattr(uri_TS, 'UsageVersion', '1000000') ;
rc = metadata_setattr(uri_TS, 'IsUserDefined', '1') ;
rc = metadata_setattr(uri_TS, 'TransformRole', 'SASUserExit') ;
* ControlOrder toevoegen aan TransformationStep ;
rc = metadata_setassn(uri_TS, 'AssociatedObjects', 'Append', 'omsobj:PhysicalTable/A5NKZYZ3.BH0004QE') ;
* Nieuwe classifierMap Toevoegen ;
rc = metadata_setassn(uri_TS, 'Transformations', 'Append', uri_CM) ;
rc = metadata_setattr(uri_CM, 'IsUserDefined', '1') ;
* Tabellen toevoegen aan ClassifierMap ;
rc = metadata_setassn(uri_CM, 'ClassifierSources', 'Append', 'omsobj:PhysicalTable/A5NKZYZ3.BH0004QE') ;
rc = metadata_setassn(uri_CM, 'ClassifierTargets', 'Append', 'omsobj:PhysicalTable/A5NKZYZ3.BH0004QF') ;
* Sourcecode toevoegen aan ClassifierMap ;
rc = metadata_setassn(uri_CM, 'SourceCode', 'Append', uri_TXT) ;
RUN ;
It generates the job, with the two tables. The data lineage works. However, when I open the job in DI Studio I get the message:
I think it has something to do with the creation of the CusomAssociation ControlOrder. When I try to create the CustomAssociation, I get a returncode -2.
Can anyone here help me out with this?
I think you are missing an argument to the metadata_newobj-function:
rc = metadata_newobj('CustomAssociation', uri_CO, 'ControlOrder', uri_job, 'CustomAssociations') ;
rc = metadata_newobj('CustomAssociation', uri_CO, 'ControlOrder', 'Foundation', uri_job, 'CustomAssociations') ;
I think you are missing an argument to the metadata_newobj-function:
rc = metadata_newobj('CustomAssociation', uri_CO, 'ControlOrder', uri_job, 'CustomAssociations') ;
rc = metadata_newobj('CustomAssociation', uri_CO, 'ControlOrder', 'Foundation', uri_job, 'CustomAssociations') ;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.