<?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 set statement - referring to a temporary dataset just created in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/set-statement-referring-to-a-temporary-dataset-just-created/m-p/548035#M151931</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is a beginner's question. Since I started programming over 6 months ago, I still struggle with how to reference to the file location and use the data sets I just created to build on them with further modifications.&lt;/P&gt;&lt;P&gt;What to choose between infile and set statement....&lt;/P&gt;&lt;P&gt;I usually go for Set statement because it's easier but in this example, SAS doesn't recognize the new data set I created&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename Orders24 '/home/XXX/my_courses/XXX/c_8568/dly_orders.sas7bdat';
libname course '/home/XXX/my_courses/XXX/c_8568';

data orders;
SET course.dly_orders;
if Order_type = 1 then Ordr_Type_Label = 'In-store';
if Order_type = 2 then Ordr_type_label = 'Catalogue';
If Order_type = 3 then Ordr_type_label = 'Web';
run;
proc print data=orders; run;

data INSTORE ;
set course.Orders (keep = Order_ID Customer_ID Order_Date Ordr_Typ_Label) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here are my questions :&lt;/P&gt;&lt;P&gt;- How can I create a new dataset from the one I just created? when I refer to &lt;STRONG&gt;course.orders&lt;/STRONG&gt;, SAS doesn't recognize it and the new variable created can't appear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log :&amp;nbsp;&lt;SPAN&gt;ERROR: The variable Ordr_Type_Label in the DROP, KEEP, or RENAME list has never been referenced.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- What is wrong with my filename statement? in the first data step, I had to refer to the file with its original name, (not the filename from the filename statement because it wouldn't work')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2019 20:08:46 GMT</pubDate>
    <dc:creator>Dublin187</dc:creator>
    <dc:date>2019-04-02T20:08:46Z</dc:date>
    <item>
      <title>set statement - referring to a temporary dataset just created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-statement-referring-to-a-temporary-dataset-just-created/m-p/548035#M151931</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is a beginner's question. Since I started programming over 6 months ago, I still struggle with how to reference to the file location and use the data sets I just created to build on them with further modifications.&lt;/P&gt;&lt;P&gt;What to choose between infile and set statement....&lt;/P&gt;&lt;P&gt;I usually go for Set statement because it's easier but in this example, SAS doesn't recognize the new data set I created&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename Orders24 '/home/XXX/my_courses/XXX/c_8568/dly_orders.sas7bdat';
libname course '/home/XXX/my_courses/XXX/c_8568';

data orders;
SET course.dly_orders;
if Order_type = 1 then Ordr_Type_Label = 'In-store';
if Order_type = 2 then Ordr_type_label = 'Catalogue';
If Order_type = 3 then Ordr_type_label = 'Web';
run;
proc print data=orders; run;

data INSTORE ;
set course.Orders (keep = Order_ID Customer_ID Order_Date Ordr_Typ_Label) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here are my questions :&lt;/P&gt;&lt;P&gt;- How can I create a new dataset from the one I just created? when I refer to &lt;STRONG&gt;course.orders&lt;/STRONG&gt;, SAS doesn't recognize it and the new variable created can't appear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log :&amp;nbsp;&lt;SPAN&gt;ERROR: The variable Ordr_Type_Label in the DROP, KEEP, or RENAME list has never been referenced.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- What is wrong with my filename statement? in the first data step, I had to refer to the file with its original name, (not the filename from the filename statement because it wouldn't work')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 20:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-statement-referring-to-a-temporary-dataset-just-created/m-p/548035#M151931</guid>
      <dc:creator>Dublin187</dc:creator>
      <dc:date>2019-04-02T20:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: set statement - referring to a temporary dataset just created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-statement-referring-to-a-temporary-dataset-just-created/m-p/548037#M151932</link>
      <description>&lt;P&gt;You don't have a data set named COURSE.ORDERS, you have a data set named WORK.ORDERS. That's because you created it with a one-word name, and so it resides in the WORK library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data set was created with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data course.orders;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then you would need to refer to it as COURSE.ORDERS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, as written, your ORDERS data set is in the WORK library, and in your SET statement, you refer to it as either ORDERS or WORK.ORDERS (it doesn't matter which).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I can see, you never need a FILENAME statement that refers to a .sas7bdat file, that doesn't seem to have any usefulness. FILENAME statements can be used to refer to external files (such as text files), they are never used to refer to SAS data sets.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 20:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-statement-referring-to-a-temporary-dataset-just-created/m-p/548037#M151932</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-02T20:22:48Z</dc:date>
    </item>
  </channel>
</rss>

