BookmarkSubscribeRSS Feed
Nipun22
Obsidian | Level 7

program -

libname cv '/home/u60697506/sasuser.v94/Permanants Libs';
libname vc '/home/u60697506/sasuser.v94/Permanants Libs';

data cv.a;
set sashelp.cars;
run;


data cv.b;
set sashelp.cars;
run;


data cv.c;
set sashelp.cars;
run;


data cv.d;
set sashelp.cars;
run;


data cv.e;
set sashelp.cars;
run;


data vc.a;
set sashelp.cars;
run;


data vc.b;
set sashelp.cars;
run;


data vc.c;
set sashelp.cars;
run;


data vc.d;
set sashelp.cars;
run;


data vc.e;
set sashelp.cars;
run;


proc datasets lib=cv;
delete a b c d e;
run;

proc datasets;
copy in=vc out=cv;
select a b c d e ;
run;
 LOG 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         
 70         proc datasets;
 71         copy in=vc out=cv;
 72         select a b c d e ;
 73         run;
 
 WARNING: IN= and OUT= are the same. Files will not be copied into themselves.
 74         
 75         
 76         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 86         

 

7 REPLIES 7
ballardw
Super User

Where is the LOG entry for the first proc datasets that you show?

 

2 library definitions that are the same physical locations are going to cause confusion in general. There can be only one physical file named a.sas7bdat in the location. That is what the in= and out= being the same means with your shown code. So there is no reason to do anything as the result would be the same.

Nipun22
Obsidian | Level 7
you mean folder should also be different though libraries are different already?
ballardw
Super User

I did not see any difference in the library locations:

libname cv '/home/u60697506/sasuser.v94/Permanants Libs';
libname vc '/home/u60697506/sasuser.v94/Permanants Libs';

Consider this log where I assign two libraries to the same location:

516  libname junk "X:\";
NOTE: Libref JUNK was successfully assigned as follows:
      Engine:        V9
      Physical Name: X:\
517
518  data junk.a;
519     set sashelp.class;
520  run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set JUNK.A has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


521
522  libname junk2 "X:\";
NOTE: Libref JUNK2 refers to the same physical library as JUNK.
NOTE: Libref JUNK2 was successfully assigned as follows:
      Engine:        V9
      Physical Name: X:\
523

Beside the note that Junk2 refers to the SAME PHYSICAL LIBRARY

when I run, which describes the contents of all the data sets in library Junk2

524  proc contents data=junk2._all_;
NOTE: Writing HTML Body file: sashtml1.htm
525  run;

I get the following result which shows data set A in Junk2.

The CONTENTS Procedure

 

Directory
Libref JUNK2
Engine V9
Physical Name X:\
Filename X:\
Owner Name DHW\ballarde
File Size 8KB
File Size (bytes) 8192

# Name Member Type Obs, Entries
or Indexes
Vars Label File Size Last Modified
1 A DATA 19 5   128KB 08/26/2024 09:41:36

The CONTENTS Procedure

 

Data Set Name JUNK2.A Observations 19
Member Type DATA Variables 5
Engine V9 Indexes 0
Created 08/26/2024 09:41:36 Observation Length 40
Last Modified 08/26/2024 09:41:36 Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label      
Data Representation WINDOWS_64    
Encoding wlatin1 Western (Windows)    

Engine/Host Dependent Information
Data Set Page Size 65536
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 1632
Obs in First Data Page 19
Number of Data Set Repairs 0
ExtendObsCounter YES
Filename X:\a.sas7bdat
Release Created 9.0401M7
Host Created X64_10PRO
Owner Name DHW\ballarde
File Size 128KB
File Size (bytes) 131072

Alphabetic List of Variables and Attributes
# Variable Type Len
3 Age Num 8
4 Height Num 8
1 Name Char 8
2 Sex Char 1
5 Weight Num 8

 

There are a few reasons to have multiple references to the same Library but for relative beginners it is more likely to cause confusion than to simplify a project.

 

A single library can point to multiple physical storage locations (folders, drives). Those locations may also be other libraries.

Example

libname newlib (junk junk2);

and the log shows

527  libname newlib (junk junk2);
NOTE: Libref NEWLIB was successfully assigned as follows:
      Levels:           2
      Engine(1):        V9
      Physical Name(1): X:\
      Engine(2):        V9
      Physical Name(2): X:\

Which means that I now have 3 different libraries all pointing to the same location: x:\

 

Which I will clear now as I don't need them after demonstrating this behavior.

 

 

 

Reeza
Super User

@Nipun22 wrote:
you mean folder should also be different though libraries are different already?

Libraries are shortcut references to physical locations. Both libraries are referring to the same physical location so they are the same. 

 

You can actually use a path in place of libraries in most code but it's much easier to use libname references.

 

So yes, use different folders 🙂

Nipun22
Obsidian | Level 7
Yeah I just changed the physical location location of the two libraries to the new subfolders and works like a charm!
Quentin
Super User

@Nipun22 wrote:
you mean folder should also be different though libraries are different already?

Yes, if you think in terms of the files, your current code is trying to copy the file

/home/u60697506/sasuser.v94/Permanants Libs/a.sas7bdat

to:

/home/u60697506/sasuser.v94/Permanants Libs/a.sas7bdat

and SAS is recognizing that you're trying to copy a file to the same place the file is already located, which doesn't make sense.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

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
  • 7 replies
  • 640 views
  • 2 likes
  • 4 in conversation