hello,
plz tell how do i use the variable unique id to the other dataset ?
as it shows the error that i have not referenced it .
The data set TEST contains UNIQUE_ID.
The data set CLASS.CAR_SALES does not.
To use TEST, it must appear on the SET statement, not the DATA statement:
data something_new;
set test;
* Now Unique_ID will be available;
run;
That error is saying you can't use it because it doesn't exist. If you run this program, you will see that UNIQUE_ID does not appear on the list of variables within the data set:
proc contents data=class.car_sales;
run;
There is no need to attach SAS program files. Please post code or log entries into a code box opened using the forum's {I} icon:
/*Assignment3*/ /*question 1*/ libname class '/folders/myfolders/mysas'; proc import datafile='/folders/myfolders/mysas/car_sales.csv' dbms=csv out=class.car_sales replace; data testdata; retain org_country; set class.car_sales; length org_country $10.; select (Manufacturer); when('BMW','Audi','Mercedes') org_country=('Germany'); when ('Honda','Toyota') org_country=('Japan'); when('Cadillac','Chevrolet','Chrysler','Dodge','Ford') org_country=('US'); when('lincoln','Jaguar','Buick') org_country=('UK'); when ('Hyundai') org_country=('south korea'); when('Acura','Lexus') org_country=('Japan'); otherwise org_country=('others'); end; run; /*question2*/ Data test; length unique_id $20; Set class.car_sales; unique_id=catt(model,manufacturer); run; /* question3*/ data test; set class.car_sales(keep= unique_id Manufacturer Model); run;
The error message is quite clear: the variable UNIQUE_ID does not exist on the data set CLASS.CAR_SALES.
You added a variable name unique_id to data set named TEST in the section labeled question 2. But you do not use that set but go back to the original data class.car_sales that did not have the variable.
Each time you use
data test;
<code>;
run;
You will completely overwrite the previous version of the data set test if there are no syntax errors. Make sure that is what you want to do.
I would suggest:
/*question2*/ Data test; length unique_id $20; Set class.car_sales; unique_id=catt(model,manufacturer); run; /* question3*/ data test2; set test(keep= unique_id Manufacturer Model); run;
if you actually need two different data sets.
Or if you want a single data set with only those three variables:
/*question2*/ Data test; length unique_id $20; Set class.car_sales; unique_id=catt(model,manufacturer); keep unique_id Manufacturer Model; run;
please tell how do i refer the unique_id to the last dataset ??
The data set TEST contains UNIQUE_ID.
The data set CLASS.CAR_SALES does not.
To use TEST, it must appear on the SET statement, not the DATA statement:
data something_new;
set test;
* Now Unique_ID will be available;
run;
We were all beginners at some point. Good to see you posting your questions.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.