DATA Step, Macro, Functions and more

Create Unique ID based on two variables

Accepted Solution Solved
Reply
Contributor
Posts: 50
Accepted Solution

Create Unique ID based on two variables

[ Edited ]

hi,

i just want to know that  how to create a Unique ID in the data set using two variables in the data set using TRIM and double pipe function ?

please give me the code ?

thanks 

sas_learner


Accepted Solutions
Solution
‎06-20-2016 07:36 AM
Respected Advisor
Posts: 4,654

Re: Create Unique ID based on two variables

Find a character which doesn't occur in your vaiables, such as "@", and create your unique ID as

 

length uniqueID $20; /* To be adjusted */

uniqueID = catx("@", var1, var2);

PG

View solution in original post


All Replies
Super User
Posts: 17,896

Re: Create Unique ID based on two variables

I'm confused, it sounds like you know what you want, are you having issues creating the variable?
If so, post the code you've used and are having issues with. I'm also uncertain as to what you mean by double pipe function. 

 

There is a double pipe that is used to represent concatenation, but in my opinion, the CAT family of functions are better, especially since they'll do things like trim by default (CATT).

Solution
‎06-20-2016 07:36 AM
Respected Advisor
Posts: 4,654

Re: Create Unique ID based on two variables

Find a character which doesn't occur in your vaiables, such as "@", and create your unique ID as

 

length uniqueID $20; /* To be adjusted */

uniqueID = catx("@", var1, var2);

PG
Contributor
Posts: 50

Re: Create Unique ID based on two variables

hi,

using  when-select statements, how can we define a new variable providing the country of each model based on the manufacturer.??

thanks ,

 

Super User
Posts: 17,896

Re: Create Unique ID based on two variables

@Prateek1 Please post your question as a new topic. 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 953 views
  • 1 like
  • 3 in conversation