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

We have a SAS code that is run in Base SAS that is run quarterly. It creates data sets in different folders on a server depending on month and the year.  Bleow is the code I was using with replacing x's where our server name and network inofrmation.  Also I included the log with the error.  Can anyone help or suggest another way of do this.  We are trying not to modify the program every time the job is schedule to run.


%macro LibPath ();
%let m = %substr(&sysdate9,3,3);
%let y = %substr(&sysdate9,6,4);
%put &m;
%put &y;

%if &m=JAN %then %do;
%let Q=E:\Loans Data\Fourth Quarter ;
%end;
%if &m=APR %then %do;
%let Q=E:\Loans Data\First Quarter ;
%end;
%if &m=JUL %then %do;
%let Q=E:\Loans Data\Second Quarter ;
%end;
%if &m=OCT %then %do;
%let Q=E:\Loans Data\Third Quarter ;
%end;

%put &Q;

%if &m=JAN %then %do;
%let y=%eval(&y - 1);
%end;
%else %do;
%let y= &y;
%end;
%put &y;


%let LibraryPath = %quote(%str(&Q &y));
%put &LibraryPath;


%let mynode=xxxxxxxx 3232;
options comamid=tcp remote=mynode;
signon;


libname PROP_DB &LibraryPath server=Mynode;

%mend;

%LibPath();

1
2    %macro LibPath ();
3    %let m = %substr(&sysdate9,3,3);
4    %let y = %substr(&sysdate9,6,4);
5    %put &m;
6    %put &y;
7
8    %if &m=JAN %then %do;
9        %let Q=E:\Loans Data\Fourth Quarter ;
10   %end;
11   %if &m=APR %then %do;
12       %let Q=E:\Loans Data\First Quarter ;
13   %end;
14   %if &m=JUL %then %do;
15       %let Q=E:\Loans Data\Second Quarter ;
16   %end;
17   %if &m=OCT %then %do;
18       %let Q=E:\Loans Data\Third Quarter ;
19   %end;
20
21   %put &Q;
22
23   %if &m=JAN %then %do;
24       %let y=%eval(&y - 1);
25   %end;
26   %else %do;
27   %let y= &y;
28   %end;
29   %put &y;
30
31
32   %let LibraryPath = %quote(%str(&Q &y));
33   %put &LibraryPath;
34
35
36   %let mynode=xxxxxxxx 3232;
37   options comamid=tcp remote=mynode;
38   signon;
39
40
41
42
43   libname PROP_DB &LibraryPath server=Mynode;
44
45 
50
51   %mend;
52
53   %LibPath();
JAN
2012
E:\Loans Data\Fourth Quarter
2011
E:\Loans Data\Fourth Quarter 2011
NOTE: Remote signon to MYNODE commencing (SAS Release 9.01.01M3P020206).
NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead.
NOTE: All profile changes will be lost at the end of the session.
NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.2 (TS2M3)
      Licensed to NY HIGHER EDUCATION SERVICES CORP, Site 70061030.
NOTE: This session is executing on the X64_ESRV08  platform.

NOTE: SAS initialization used:
      real time           0.34 seconds
      cpu time            0.39 seconds

NOTE: Remote signon to MYNODE complete.
ERROR: The E engine cannot be found.
ERROR: Error in the LIBNAME statement.
ERROR: Libname PROP_DB is not assigned.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds

Thanks for your help.  I hope that I chose the right area.

Bridget Nelson

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Did you try just adding quotes around the path that you have calculated?

libname PROP_DB %sysfunc(quote(&LibraryPath)) server=Mynode;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Did you try just adding quotes around the path that you have calculated?

libname PROP_DB %sysfunc(quote(&LibraryPath)) server=Mynode;

Bridget53
Calcite | Level 5

Thanks Tom it work. We spent most of the morning trying to work on it and just could not figure out how to get the quotes there.  Thanks again.

FriedEgg
SAS Employee

You could also literally add the quotes:

libname PROP_DB "&LibraryPath" server=Mynode;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 717 views
  • 0 likes
  • 3 in conversation