<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic using a variable from a dataset to the other dataset . in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535919#M7055</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;plz tell how do i use the variable unique id to the other dataset ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;as it shows the error that i have not referenced it .&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="sasSource"&gt;73 data test;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 set class.car_sales(keep= unique_id Manufacturer Model);&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: The variable unique_id in the DROP, KEEP, or RENAME list has never been referenced.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Data set WORK.TEST was not replaced because this step was stopped.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.03 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.02 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;89&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Feb 2019 17:19:38 GMT</pubDate>
    <dc:creator>Shrutibhatnagar</dc:creator>
    <dc:date>2019-02-15T17:19:38Z</dc:date>
    <item>
      <title>using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535919#M7055</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;plz tell how do i use the variable unique id to the other dataset ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;as it shows the error that i have not referenced it .&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="sasSource"&gt;73 data test;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 set class.car_sales(keep= unique_id Manufacturer Model);&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: The variable unique_id in the DROP, KEEP, or RENAME list has never been referenced.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Data set WORK.TEST was not replaced because this step was stopped.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.03 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.02 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;89&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535919#M7055</guid>
      <dc:creator>Shrutibhatnagar</dc:creator>
      <dc:date>2019-02-15T17:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535939#M7056</link>
      <description>&lt;P&gt;That error is saying you can't use it because it doesn't exist.&amp;nbsp; If you run this program, you will see that UNIQUE_ID does not appear on the list of variables within the data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=class.car_sales;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535939#M7056</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-15T17:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535940#M7057</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;/*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;
&lt;/PRE&gt;
&lt;P&gt;The error message is quite clear: the variable UNIQUE_ID does not exist on the data set CLASS.CAR_SALES.&lt;/P&gt;
&lt;P&gt;You added a variable name unique_id to data set named TEST&amp;nbsp;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each time you use&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;lt;code&amp;gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;I would suggest:&lt;/P&gt;
&lt;PRE&gt;/*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;&lt;/PRE&gt;
&lt;P&gt;if you actually need two different data sets.&lt;/P&gt;
&lt;P&gt;Or if you want a single data set with only those three variables:&lt;/P&gt;
&lt;PRE&gt;/*question2*/
Data test;
   length unique_id $20;
   Set class.car_sales;
   unique_id=catt(model,manufacturer);
   keep  unique_id Manufacturer Model;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535940#M7057</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-15T17:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535958#M7058</link>
      <description>&lt;P&gt;please tell how do i refer the unique_id to the last dataset ??&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 18:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/535958#M7058</guid>
      <dc:creator>Shrutibhatnagar</dc:creator>
      <dc:date>2019-02-15T18:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/536017#M7059</link>
      <description>&lt;P&gt;The data set TEST contains UNIQUE_ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data set CLASS.CAR_SALES does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use TEST, it must appear on the SET statement, not the DATA statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data something_new;&lt;/P&gt;
&lt;P&gt;set test;&lt;/P&gt;
&lt;P&gt;* Now Unique_ID will be available;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 19:59:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/536017#M7059</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-15T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/536115#M7060</link>
      <description>ok thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; i am just a beginner .</description>
      <pubDate>Sat, 16 Feb 2019 03:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/536115#M7060</guid>
      <dc:creator>Shrutibhatnagar</dc:creator>
      <dc:date>2019-02-16T03:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable from a dataset to the other dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/536162#M7062</link>
      <description>&lt;P&gt;We were all beginners at some point.&amp;nbsp; Good to see you posting your questions.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2019 15:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/using-a-variable-from-a-dataset-to-the-other-dataset/m-p/536162#M7062</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-16T15:08:16Z</dc:date>
    </item>
  </channel>
</rss>

