BookmarkSubscribeRSS Feed
sunshineca55
Calcite | Level 5

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.

2 REPLIES 2
ballardw
Super User

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.

 

sunshineca55
Calcite | Level 5

Thank you so much, this worked really well 🙂

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1012 views
  • 1 like
  • 2 in conversation