Have you ever assigned a universal unique identification (UUID) to a data set in SAS 9.4 or SAS EG? We need to prep our datasets for SQL database and we need to make sure each observation from one data set share the same UUID that is different from all other datasets.
What you describe sounds like you want UUID per observation.
If you mean to add an identifier then you may be looking for the UUIDGEN function. The example data set creates a 32 character id using the function. If you don't assign a length for the variable it will default to 200 characters.
data example; length id $ 32; do i=1 to 10; id = uuidgen(); output; end; run;
If you want the same value for all records in a data set you would use something like
data want; set have; length id $ 32; retain id; if _n_=1 then id = uuidgen(); run;
Or generate a single value one record data set and use a join in Proc SQL to add the value to all the records.
Thank you so much, this worked really well 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.