BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dublin187
Calcite | Level 5

Hi all,

 

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.

What to choose between infile and set statement....

I usually go for Set statement because it's easier but in this example, SAS doesn't recognize the new data set I created 

 

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;

Here are my questions :

- How can I create a new dataset from the one I just created? when I refer to course.orders, SAS doesn't recognize it and the new variable created can't appear. 

Log : ERROR: The variable Ordr_Type_Label in the DROP, KEEP, or RENAME list has never been referenced.

 

- 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')

 

Thank you in advance for your help

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

 

If your data set was created with 

 

data course.orders;

then you would need to refer to it as COURSE.ORDERS.

 

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).

 

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.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

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.

 

If your data set was created with 

 

data course.orders;

then you would need to refer to it as COURSE.ORDERS.

 

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).

 

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.

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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