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

DATA A;

INPUT  LIBREF$   PATH$;

CARDS;

MYLIB     C:\SAS\SAI

MYSAS    D:\SAS\RAJA

MYXYZ    E:\SAS\RANI

;

RUN;

 

HERE  LIBRARY HAS TO CREATE AS MYLIB  IN GIVEN PATH C:\SAS\SAI

LIKE THAT ONE MORE LIBRARY HAS TO CREATE AS MYSAS IN GIVEN PATH D:\SAS\RAJA......

 

 

CAN I GET CODE FOR THIS THANK YOU...

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Please do not type in all capitals

 

 

DATA A;
    INPUT  LIBREF$   PATH $18.;
    call execute(cat('libname ',libref,'"',trim(path),'";'));
CARDS;
MYLIB     C:\SAS\SAI
MYSAS    D:\SAS\RAJA
MYXYZ    E:\SAS\RANI
;

 

 

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Please do not type in all capitals

 

 

DATA A;
    INPUT  LIBREF$   PATH $18.;
    call execute(cat('libname ',libref,'"',trim(path),'";'));
CARDS;
MYLIB     C:\SAS\SAI
MYSAS    D:\SAS\RAJA
MYXYZ    E:\SAS\RANI
;

 

 

--
Paige Miller
Saikiran_Mamidi
Obsidian | Level 7

Very Happy with the code

 

Can you please explan the code call execute ?

ballardw
Super User

@Saikiran_Mamidi wrote:

Very Happy with the code

 

Can you please explan the code call execute ?


The CALL EXECUTE creates strings that are placed in the compiler buffer for execution after the data step completes.

PaigeMiller
Diamond | Level 26

@Saikiran_Mamidi wrote:

Very Happy with the code

 

Can you please explan the code call execute ?


CALL EXECUTE generates SAS code that is run after the DATA step finishes.

 

So after the data step finishes, the first line created by CALL EXECUTE is:

 

libname MYLIB   "C:\SAS\SAI";

and this runs, then the next line created runs, and so on.

--
Paige Miller
Reeza
Super User

Typing in all caps is yelling on the internet and it's actually hard to read. Please format your questions. 

 

To answer your question use the LIBNAME() function.https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p1bq8nyxm7y1ygn1i4vyf82z68ls.htm...

 

RC is the return code which indicates if the function was successful.

 

DATA A;

INPUT  LIBREF$   PATH$;
rc = libname(libref, path); CARDS; MYLIB C:\SAS\SAI MYSAS D:\SAS\RAJA MYXYZ E:\SAS\RANI ; RUN;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 806 views
  • 3 likes
  • 4 in conversation