BookmarkSubscribeRSS Feed
rajat1
Fluorite | Level 6

Make 2 separate data sets containing the variable

1.  unique id ,Manufacturer,model

2. unique id  and remaining variable

 

I AM NOT HAVING A UNIQUE ID IN MY DATA SET IN  THIS CASE . WHAT SHOULD I DO ?

 

Data set is :-

ManufacturerModelSales in thousands4-year resale valueVehicle type       
excsds111.31311.26Car       
abcfgfvg101.323.Car       
xxxdfrg181.74912.025Car       
aaaEscort           70.2277.425Passenger       

 

 

code:

 

Data a_sales ;
set _class_s.a_sales;
keep  Manufacturer Model ;
run;  

proc print data=a_sales;
run;

             
Data a_sales ;
set _class_1.a_sales;
drop Manufacturer Model ;
run;

proc print data=a_sales;
run;


 


 

1 REPLY 1
jklaverstijn
Rhodochrosite | Level 12

It would help if you more clearly explained your problem. I go by the assumption that you do not have a unique id and want a way to make one.

 

"If" manufacturer and model together are unqiue, this would be one way:

 

Data a_sales ;
set _class_s.a_sales;
keep  Unique_id Manufacturer Model ;
Unique_id = md5(cats(Manufacturer, Model));
run;  

proc print data=a_sales;
run;

             
Data a_sales ;
set _class_1.a_sales;
drop Manufacturer Model ;
Data a_sales ;
set _class_s.a_sales;
keep  Manufacturer Model ;
run;  

proc print data=a_sales;
run;

             
Data a_sales ;
set _class_1.a_sales;
drop Manufacturer Model ;
Unique_id = md5(cats(Manufacturer, Model));
run;

proc print data=a_sales;
run;



run;

proc print data=a_sales;
run;


MD5() or it's more modern sibling SHA256() make a hash of it's character argument in a reproducable way. Another approach would take the row number but that can change and is not my preference. But it's up to you.

 

Hope this helps,

- Jan.

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