I have defined a proc format and a macro which looks for example like below. I want myfolder on my gpath to be replaced with the defined formats. For example format &myfolder $folder.;
proc format library = ft; value $folder 'foldernameA'= 'foldername A containing books' 'foldernameB'= 'foldernameB containing pencils' ; run; %macro gdesign (myfie, myfolder);
***********some sas codes*****************; ods listing gpath= "C:\graphs\&myfolder "; ***********some sas codes*****************; %mend gdesign;
If I place this on the gpath ( like this:
ods listing gpath= "C:\graphs\format &myfolder $folder. ";
) I get an error
Is there any way to do that?
That is not really the place for formats, formats are applied to Data in Datasets. You could fool it by using combinations of sysfunc and functins, but there really is no need. You would use macro to do this kind of find/replace e.g (and you need to supply a concrete example of input/output for exact code):
%gdesign(folder1,foldername A containing books); %gdesign(folder1,foldername B containing pencils);
Thanks this worked fine. The only problem I still have is that . I need to use this in many macros, that means I have to type in this long name always. I wish to store this in a variable so that if I call the variable it outputs foldername A contain books
Is there any way out
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.