BookmarkSubscribeRSS Feed
Andres_Fuentes1
Calcite | Level 5

dear, I hope you are very well, how can I create a unique id and  that is a combination of the entire row of a database?

2 REPLIES 2
ballardw
Super User

How many variables and of what types are they? Are any of the variables dates or times and do you need to see the date in that variable? Do any of the numeric variables have decimal portions and if so, how much to want to see?

How many variables have missing values? How should the missing values appear in the result?

 

You can try something like:

 

data want; 
   set have;
   length uniqueid $ 500; /*<= this number needs to be large enough to represent the maximum number of characters that might result*/
   uniqueid = cats(of _all_);
run;

Though I won't be surprised if you don't like the result.

AllanBowe
Barite | Level 11

Hi Andres,

 

This macro can be used to take a hash of all the values.  It will work with high precision decimals, special missings, and very wide character variables.

 

It's the same algorithm we use to diff uploads in Data Controller for SAS.  The ID will have a length of $32.

 

https://core.sasjs.io/mp__md5_8sas.html

 

Best,

Allan

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

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 Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 256 views
  • 0 likes
  • 3 in conversation