BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
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.

1 ACCEPTED SOLUTION

Accepted Solutions
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.

 

View solution in original post

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 🙂

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
  • 1555 views
  • 1 like
  • 2 in conversation