I need to load row number in sas DI.
For Eg: In Source
Name Emp_ID
Raj 123
Kumar 456
. .
. .
Ravi 789
My target must be like this.
Name Emp_ID Row_No.
Raj 123 1
Kumar 456 2
. . .
. . .
Ravi 789 35
How to do this? Pls help me on this.
Hi Helannivas ,
IF u want row number in sas DI
Use Surrogate Key transformation in this transformation properties create new column(Row _NO) in target table and mapping to source column emp_ID to target table column Row_NO)..
Thanks for your reply...
We are not using any primary keys constraint in my target table.
We are loading from flat file to table.I tried using surrogate key generator.
The surrogate key columns is not getting updated.
How to proceed further?
I have never done it but you can use Row_no = _n_;
Hi,
1. Use a user written transformation and table loader to solve the problem.
use the below code in the user written transformation;
data _output_;
set <your source>;
Row_NUM=_n_;
run;
2. Connect out put of this transformation to Table loader and table loader to your output data set.
Please let me know if you have any concerns.
Thanks,
Chakra..
Thanks for your reply...
I have used monotonic() function for row number and its working fine.
I have one more question.
My source files has some null values.For Eg.
Name Emp_Id
Raj 123
null 456
I need to load as empty string in target.I have used coalesce function (coalescec(Name,' ')) .
But still i am not getting the o/p.
Pls help me on this.
Try this coalescec('Name',' ')
When I used coalescec('Name',' ' ),the Name column has the values as name in both the rows.(like this)
Name Emp_Id
Name 123
Name 456
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!
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.