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

Hey everyone,

 

I am having trouble creating a permanent table for an activity in the Programming Course. More specifically:

 

"Write a DATA step to read the pg1.np_species table and create a new table named fox.
Note: If you are using SAS Studio, try creating fox as a permanent table in the EPG194/output folder"

 

* if you are creating a permanent table, you must submit a LIBNAME statement and then reference out.fox;
* libname out "path-to-EPG194/output"; 

I am able to perform the steps and processes after this but for some reason I can't create a permanent table for this solution. It isn't required, but I want to know my mistake to better understand SAS. Below is my code.

 

 

libname out.fox;
libname out "/folders/myfolders/EPG194/output";

data fox;
set pg1.np_species;
where Category='Mammal' and upcase(Common_Names) like '%FOX%';
drop Category Record_Status Occurrence Nativeness;
run;

 Thanks for the assistance.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
*This does nothing;
libname out.fox;

*This creates a permanent library - output folder must exist already;
libname out "/folders/myfolders/EPG194/output";

*you have not specified the library so your data set is saved to WORK;
data fox;
    set pg1.np_species;
    where Category='Mammal' and upcase(Common_Names) like '%FOX%';  
    drop Category Record_Status Occurrence Nativeness;
run;

The correct code is as follows:


libname out "/folders/myfolders/EPG194/output";

data out.fox;
    set pg1.np_species;
    where Category='Mammal' and upcase(Common_Names) like '%FOX%';  
    drop Category Record_Status Occurrence Nativeness;
run;

View solution in original post

4 REPLIES 4
mkeintz
PROC Star

The LIBNAME statement is only meant to associate a symbolic name (OUT in your example) to a location (or a set of location, but we don't need to go into that here).

 

References to data sets (or "table" in you example) are not made in a libname statement, but are made in DATA statements, SET, MERGE or a few other statements).    I.e. that's where two-level names (libname.tablename) can occur.

 

So what did you sas log say

  1. About the libname out.fox statement
  2. What two-level name was created by your DATA step?

 

regards,

Mark

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
fabroomeiv
Fluorite | Level 6

Sorry for the delay, I just started working and that took up the last few days. I figured out the issue. I wasn't referencing out correctly, and the path to the output folder somehow changed, making my reference incorrect. It is fixed now. Thank you for the help and explanation.

Reeza
Super User
*This does nothing;
libname out.fox;

*This creates a permanent library - output folder must exist already;
libname out "/folders/myfolders/EPG194/output";

*you have not specified the library so your data set is saved to WORK;
data fox;
    set pg1.np_species;
    where Category='Mammal' and upcase(Common_Names) like '%FOX%';  
    drop Category Record_Status Occurrence Nativeness;
run;

The correct code is as follows:


libname out "/folders/myfolders/EPG194/output";

data out.fox;
    set pg1.np_species;
    where Category='Mammal' and upcase(Common_Names) like '%FOX%';  
    drop Category Record_Status Occurrence Nativeness;
run;
fabroomeiv
Fluorite | Level 6

Thanks for the help and explanation. I initially had the path to the output folder wrong. When it didn't reference out I got confused and started making more mistakes.