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

hi folks - 

 

I have got the following directory and need to be changed automatically once I change the years.

 

%let dir2=M:\Lib\T9099H0103Y\T9099H0103Y_CO;

libname coeficents "&dir2"

 

%let DT=90;

%let UT=99;

%let DH=01;

%let UH=03;

 

To be clearer, I want by changing DT, UT,DH and UH  the directory path changes. thanks 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You will need to move the %LET statements so that they come before the directory path:

 

%let DT=90;

%let UT=99;

%let DH=01;

%let UH=03;

 

%let dir2=M:\Lib\T&DT.&UT.H&DH.&UH.Y_CO;

libname coeficents "&dir2";

 

It's not clear from your post whether these are the exact changes to make to the directory path, but this gives you the technique to apply.

 

Good luck.

View solution in original post

10 REPLIES 10
Reeza
Super User

I'm not following, please explain your problem further.

Moh
Obsidian | Level 7 Moh
Obsidian | Level 7

 

 For example I have got this dir path;

%let dir2=M:\Lib\T9099H0103Y;

libname coeficents "&dir2"

 

Now i want to change the path according to the following items

%let DT=91;

%let UT=97;

%let DH=02;

%let UH=05;

 

to have this new directory at the end;

%let dir2=M:\Lib\T9197H0205Y;

 

 

Reeza
Super User

I don't understand still...I guess you could use a macro.But how did the mapping occur? How do you know to switch from

 

 

 

Is it something like:

 

%let dir2= M:\Lib\&DT.&UT.H&DH.&UH.Y;

libname coeficents "&dir2"

Moh
Obsidian | Level 7 Moh
Obsidian | Level 7

Your question is not clear. I have the results of about 100 types of models which are developed using different training samples and will be tested on different holdout samples. So I need to arrange them in different folders and name the folders based on training sample (e.g. T9199 ) which mean 1991 to 1999 and holdout sample (e.g. H0105) which means 2001 to 2005. 

However, your answer helped me a lot. thanks 

Reeza
Super User

A libname can only be 8 characters, your current name is too long.

 

You don't need two macro variables as well, can use one directly.

 

%let DT=90;

%let UT=99;

%let DH=01;

%let UH=03;

 

 

libname mylib  "M:\Lib\T&DT.&UT.H&DH.&UH.Y;";

Astounding
PROC Star

You will need to move the %LET statements so that they come before the directory path:

 

%let DT=90;

%let UT=99;

%let DH=01;

%let UH=03;

 

%let dir2=M:\Lib\T&DT.&UT.H&DH.&UH.Y_CO;

libname coeficents "&dir2";

 

It's not clear from your post whether these are the exact changes to make to the directory path, but this gives you the technique to apply.

 

Good luck.

Moh
Obsidian | Level 7 Moh
Obsidian | Level 7

It's not working !!!!

Astounding
PROC Star

This is a short enough program that you should be able to post your program and the log from it.

Reeza
Super User

That's too bad....but we have no idea what that means. 

ballardw
Super User

Did you change the LIBNAME to 8 characters?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 10 replies
  • 1498 views
  • 0 likes
  • 4 in conversation