BookmarkSubscribeRSS Feed
mnjtrana
Pyrite | Level 9

Hi ALL,

 

I am trying to use the below code to export my log from SAS Enterprise Guide 6.1 to a specified location based on the program name?

 

So basically i want to find out the program name so that i can put the below code in the SAS enterprise guide

Option->sas programs ->Additional sas code ->Insert custom SAS code before submitted code

 

We have a grid environment, where we are using a Linux server to execute the code and frontend is SAS EG 6.1


%let Name = TEST1;
%let pgm_name = /* need help here */;
%let today= %sysfunc(putn(%sysfunc(today()),yymmddn8.));

proc printto  log = "/sas/develop/admin/&name./dev/logs/&pgm_name._&today..txt" new;
run;

i have tried many ways, but could not find any for doing this in interactive mode.

 

 

Thanks in Advance,

 

Manjeet


Cheers from India!

Manjeet
9 REPLIES 9
tbellmer_wf
Fluorite | Level 6

%macro pgmname() ;

   %local retval ;

   %let retval = %sysfunc( getoption( sysin ) ) ; /* batch mode */

   %if %isblank( &retval. ) %then %let retval = &_SASPROGRAMFILE ; /* interactive mode */

   /* next line removes single quotes produced in interactive mode */

   %qsysfunc( compress( &retval., %str(%') ) )

%mend ;

Tom
Super User Tom
Super User

What????


@tbellmer_wf wrote:

 


...

   /* next line removes single quotes produced in interactive mode */

   %qsysfunc( compress( &retval., %str(%') ) )

... 


Why would you want to remove ALL of the quotes from a string?  Wouldn't that make any string that includes quotes invalid?

Are you trying to remove the outer quotes around the string?

%qsysfunc(dequote(&retval.))

 

tbellmer_wf
Fluorite | Level 6
Feel free to modify as you desire. I needed to do that for my purposes.
mnjtrana
Pyrite | Level 9
@tbellmer_wf thanks for the help.

However the &_SASPROGRAMFILE variable doesn't exist in the SAS Eg. So this code won't help.

Cheers from India!

Manjeet
tbellmer_wf
Fluorite | Level 6
Oh but it actually does as I use this all the time. Apparently there are a few caveats so be sure to read this note: http://support.sas.com/kb/59/744.html
error_prone
Barite | Level 11
Take care to backup the code you added to EG options. Afaik the code is stored somewhere in %userprofile% directory, so if those directories aren't backuped all code is lost when the hard disk dies.

@tbellmer_wf are you sure, that _sysprogramfile exists in EG-sessions? Thought that this variable is only created in Studio, batch and display-manager sessions.
mnjtrana
Pyrite | Level 9

@error_prone - you are right, the &_SASPROGRAMFILE variable doesn't exist in SAS Eg interactive mode. We have to search for other options.

 

Thanks for the help!


Cheers from India!

Manjeet
error_prone
Barite | Level 11

Afaik no variable holding the program-name exists. The variable _ClientProjectPath has name and path of the EG-project. If you are using macros SysMacroName has the name of macro being executed, there could be a function returning the path of the macro. Can't verify this right now.

Ksharp
Super User
%let x=%sysget(sas_execfilename);
%let y=%sysget(sas_execfilepath);

%put &x ;
%put &y ;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 9 replies
  • 3464 views
  • 4 likes
  • 5 in conversation