Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:12:54+00:00 2026-06-13T00:12:54+00:00

I am trying to figure out how to create a dynamic library reference. I

  • 0

I am trying to figure out how to create a dynamic library reference. I have figured out how to create directories, but now: how to create library references properly?

The code below works, but it required a repeat of the code. The first block does not create a reference, but the second one does. Putting the same into a loop (to execute lines twice) does not work…

I would like to redo this code into a macro, so that the root directory would be assigned when calling the macro.

Thanks in advance!

data _null_;
rootdir='c:/temp';
dir1=put(today(),yymmddn8.);
dir2='Individual';
dir3='Household'; 
newdir1=dcreate(dir1,rootdir);
newdir2=dcreate(dir2,newdir1); 
newdir3=dcreate(dir3,newdir1);
lname=catx('/',rootdir,dir1,dir2);
lname2=catx('/',rootdir,dir1,dir3);
call symput('ln1',lname);
call symput('ln2',lname2);
libname Indiv "&ln1";
libname HH "&ln2";
run;

data _null_;
rootdir='c:/temp';
dir1=put(today(),yymmddn8.);
dir2='Individual';
dir3='Household'; 
lname=catx('/',rootdir,dir1,dir2);
lname2=catx('/',rootdir,dir1,dir3);
call symput('ln1',lname);
call symput('ln2',lname2);
libname Indiv "&ln1";
libname HH "&ln2";
run;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:12:55+00:00Added an answer on June 13, 2026 at 12:12 am
    %macro libs(rootdir);
    data _null_;
    dir1=put(today(),yymmddn8.);
    dir2='Individual';
    dir3='Household'; 
    newdir1=dcreate(dir1,&rootdir);
    newdir2=dcreate(dir2,newdir1); 
    newdir3=dcreate(dir3,newdir1);
    call symput('ln1',catx('/',&rootdir,dir1,dir2));
    call symput('ln2',catx('/',&rootdir,dir1,dir3));
    run;
    libname Indiv "&ln1";
    libname HH "&ln2";
    %mend libs;
    
    %libs("c:/temp")
    

    Seems to do the trick. Not sure if the most efficient way of doing it, but at least it is a way. Thank you Joe for the suggestions that led me to the final answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how to create 3 divs and have them
I'm trying to figure out how to create a dynamic context, and what I
I'm trying to figure out how to create a dynamic case statement in a
I'm trying to figure out how to create an Item Template but according to
I'm trying to figure out if there is some way to create a dynamic
I am trying to figure out how to create a temporary table that is
I am trying to figure out how to create an image gallery like the
I'm trying to figure out how to create a http CRAN-repository. I've tried to
i am trying to figure out how to create a javascript alert box asking
I'm trying to figure out how to create personalized urls for double-byte languages. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.