Pointing to a folder location

  • Follow


Hi,

I'm trying to let final user enter the directory location at the
beginning of the code instead of re-writing it all over the place. I
have another text file that reads into the code as well which might be
causing the problem.  I've pasted a snippet below. Any insight is
appreciated.



%let folderlocation = \\abcd\My Documents\; 	/* this is where the user
enters the folder location*/

libname lib_x '"&folderlocation"';
libname output_x "&folderlocation\output_x";

%include "&folderlocation\data\macro01.sas" ;
%include "&folderlocation\data\macro02.sas" ;
%let variablelist= &folderlocation\input\variablelist.txt;
	infile "&folderlocation\input\variables.txt";
0
Reply lunacaelum (3) 7/22/2010 12:21:05 PM

On Jul 22, 5:21=A0am, cael <lunacae...@gmail.com> wrote:
> Hi,
>
> I'm trying to let final user enter the directory location at the
> beginning of the code instead of re-writing it all over the place. I
> have another text file that reads into the code as well which might be
> causing the problem. =A0I've pasted a snippet below. Any insight is
> appreciated.
>
> %let folderlocation =3D \\abcd\My Documents\; =A0 =A0 /* this is where th=
e user
> enters the folder location*/
>
> libname lib_x '"&folderlocation"';
> libname output_x "&folderlocation\output_x";
>
> %include "&folderlocation\data\macro01.sas" ;
> %include "&folderlocation\data\macro02.sas" ;
> %let variablelist=3D &folderlocation\input\variablelist.txt;
> =A0 =A0 =A0 =A0 infile "&folderlocation\input\variables.txt";

So what's the question?
0
Reply huang8012 (261) 7/22/2010 3:03:28 PM


You can make your code easier by pointing a FILEREF at the folder that
is storing text files like raw data or programs.
For example:

* Set folder location here ;
%let folderlocation = \\abcd\My Documents\;

* Set input variable list here ;
%let variablelist=My Vars.txt;

* Define input and output librefs and filerefs ;

libname output "&folderlocation\output_x";
libname input "&folderlocation\input" access=readonly;
filename sascode "&folderlocation\data";
filename input "&folderlocation\input";

%inc sascode(macro01);
%inc sascode("macro02.sas");

data .... ;
   infile input("&variablelist") ...... ;
   ....
run;



0
Reply Tom 7/23/2010 2:24:48 AM

%let folderlocation = \\abcd\My Documents\;  -> ends with a backslash;

libname output_x "&folderlocation\output_x";  .> adds another
backslash

The resolved path in the libname statement will be: \\abcd\My Documents
\\output_x
-> the doubled backslash after "My Documents" will cause issues

HTH
Patrick
0
Reply Patrick 7/23/2010 8:56:36 AM

3 Replies
219 Views

(page loaded in 0.268 seconds)

Similiar Articles:













7/9/2012 11:37:08 AM


Reply: