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
MacroCore library for app developers
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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