0

This is the first step which would be used throughout all the project later:

(a) Create a macro variable using a %LET statement called ‘directory'where you can type the name of the directory that contains all the files of interest for this project.

(b) Create a temporary library called ‘datapath’ that links to this directory in part (a)

my code:

%let directory = C:\users\downloads;    
%LET directory = 'C:\users\Downloads';     
Libname datapath &directory.;    
run;
3
  • What is your question? How to do (a) and (b)? What did you tried so far? Please edit your question.
    – jogo
    Dec 6, 2015 at 18:08
  • thx for advice! already edited it, have any idea about it ?
    – DUKEANDY
    Dec 7, 2015 at 1:40
  • Welcome to Stack Overflow. You appear to have defined 'directory' twice, in your question at least and the 'run' statement would not be necessary at that point. If you're just not sure if your code works try it and if it doesn't work you might get a message that will help you resolve your problem, in which case post your answer to help others who are in a similar situation. If you still cannot resolve your problem then edit the question again to show what message you received. Also, consider first using: 'options symbolgen mprint;' which should show you what your macro code resolves to.
    – Amir
    Dec 7, 2015 at 8:23

2 Answers 2

2

in SAS 9.3 the following works:

%let libtest = test;                   /* &libtest   --> name of library */   
%LET directory = 'C:\users\Downloads'; /* &directory --> location on disk */
%let table = table;                    /* &table     --> name of dataset in library test  */
Libname &libtest &directory;

To test:

data &libtest..&table;
x=0;
run;
0

I don't really know what your question is, but if you are having issues, try using double quotes instead of single quotes. That works for me sometimes. Also, you created a macro variable called directory, then immediately overwrote it. You also don't need that "run;" statement at the end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.