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
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.
I'm not following, please explain your problem further.
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;
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"
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
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;";
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.
It's not working !!!!
This is a short enough program that you should be able to post your program and the log from it.
That's too bad....but we have no idea what that means.
Did you change the LIBNAME to 8 characters?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.