Copy and rename a file into another folder

Accepted Solution Solved
Reply
Contributor
Posts: 55
Accepted Solution

Copy and rename a file into another folder

I am supposed to use one DATA statement and 2 LIBNAME steps to copy the SAS data set in the ‘1 – Source’ folder named ‘ndi’ into the ‘2 – Tabulations’ folder as a data set named ‘Src_ndi’. I am confused exactly how to do this with these specific steps.

 


Accepted Solutions
Solution
‎09-11-2017 10:32 AM
Frequent Contributor
Posts: 110

Re: Copy and rename a file into another folder

Posted in reply to marianhabesland

libname source "/folders/myfolders/BIOS6680/Hypertension Study/1 - Data";

libname target "/folders/myfolders/BIOS6680/Hypertension Study/1 - Data/2 - Tabulations";

 

data target.SRC_NDI;

  set source.NDI.;

run;

View solution in original post


All Replies
Super User
Posts: 22,591

Re: Copy and rename a file into another folder

Posted in reply to marianhabesland

I suspect this is homework, so I"m going to ask, what exactly is the question and which part specifically are you having difficulty with?

Contributor
Posts: 55

Re: Copy and rename a file into another folder

This is the complete question:

Task:  Within the Hypertension Study, use the DATA step to copy the SAS data set in the ‘1 – Source’ folder named ‘ndi’ into the ‘2 – Tabulations’ folder as a data set named ‘Src_ndi’ (per the ‘Hypertension Study – Data Map.xlsx’ file).

 

Note:  Your code should include 2 LIBNAME statements and 1 DATA step.

 

I am struggling how I combine the LIBNAME statements and DATA steps to actually both copy and move the file

 

The specific locations of the folders I am trying to 

Trying to move file from:

/folders/myfolders/BIOS6680/Hypertension Study/1 - Data;

TO

/folders/myfolders/BIOS6680/Hypertension Study/1 - Data/2 - Tabulations;

 

Super User
Posts: 22,591

Re: Copy and rename a file into another folder

Posted in reply to marianhabesland

Forget the question for a second. 

Show us the two libname statements to the folders you need.

Contributor
Posts: 55

Re: Copy and rename a file into another folder

These are the statements I initially tried, but am unsure if this is what I was supposed to do

LIBNAME Source /folders/myfolders/BIOS6680/Hypertension Study/1 - Data/1 - Source
LIBNAME Tabs /folders/myfolders/BIOS6680/Hypertension Study/1 - Data/2 - Tabulations

Contributor
Posts: 55

Re: Copy and rename a file into another folder

Posted in reply to marianhabesland

EDIT

These are the statements I initially tried, but am unsure if this is what I was supposed to do

LIBNAME Source /folders/myfolders/BIOS6680/Hypertension Study/1 - Data/1 - Source;
LIBNAME Tabs /folders/myfolders/BIOS6680/Hypertension Study/1 - Data/2 - Tabulations;

Super User
Posts: 22,591

Re: Copy and rename a file into another folder

Posted in reply to marianhabesland

That's not correct. The paths need to be quoted. 

If you run the code I assume you're still getting errors. I need to sleep now but if you search on here re 'permanent sas data sets' you'll find lots of examples. 

 

Other good resources:

videos.sas.com -> how to section 

lexjansen.com -> search any topic for user written papers

here -> the Analytics U forum has a lot of beginner related questions and answers

SAS UE Help Centre 

 

Solution
‎09-11-2017 10:32 AM
Frequent Contributor
Posts: 110

Re: Copy and rename a file into another folder

Posted in reply to marianhabesland

libname source "/folders/myfolders/BIOS6680/Hypertension Study/1 - Data";

libname target "/folders/myfolders/BIOS6680/Hypertension Study/1 - Data/2 - Tabulations";

 

data target.SRC_NDI;

  set source.NDI.;

run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 392 views
  • 0 likes
  • 3 in conversation