Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt collectcode option for non-standard location of autoexec files #25

Open
cttnguyen opened this issue Feb 9, 2023 · 4 comments
Open

Comments

@cttnguyen
Copy link

I was able to use your package calling SAS from a corporate server, and so far it's been awesome!
I had to set several of the SAS options, where basically everything is in a different location: SAS, the SAS config file, and the autoexec file, and my working directory.

To do so, I had been using the following in my sasopts. This works fine when I don't want to use collectcode. The sysparm options are for setting certain system environment parameters that are required for this particular autoexec file.

"-autoexec /serverpath/autoexec.sas -sysparm var1=sysparam1,var2=sysparam2"

If I understand correctly how collectcode works, then applying the option to a code chunk will write that code chunk to the end of the autoexec. However, this is not working in my situation where my autoexec does not exist within my working directory and cannot be edited in its original directory. My current workaround is to make a new autoexec. It looks something like this, where I had to set some environment variables that are needed for passing through to the autoexec.

%let var1=sysparam1;
%let var2=sysparam2;
%include "/serverpath/autoexec.sas";

Would it be possible to expand this function to additionally look for the autoexec in a defined location, then write and use a temporary new autoexec file with the arguments for the autoexec and system parameters?

@Hemken
Copy link
Owner

Hemken commented Feb 9, 2023 via email

@cttnguyen
Copy link
Author

Well, the sysparm you can set as a command line option, in the code chunk where you load the SASmarkdown library.

Do you have an example of this? I'm worried that the system parameter would be set in the R working directory while knitting and not the SAS/server working directory when setting up the SAS session for the job.

I'm pretty novice at SAS, and looking through how our SAS server and autoexec files are organized, I'm completely lost.

Some of the arguments going in are things such as my user id and additional paths to more autoexec files that are project-specific. As in there's a high level autoexec file to define set up for any user, followed by project-level files to further tailor the set up such that all programmers on the same project are in sync with one another.

@Hemken
Copy link
Owner

Hemken commented Feb 10, 2023 via email

@cttnguyen
Copy link
Author

Oh I see. Yes that's what I had been doing prior to testing with collectcode:

sasopts <- paste0(
  c(
    "-sysparm var1=%s,var2=%s",
    "-config %s",
    "-autoexec %s",
    "-noterminal",
    "-work %s",
    "-print %s",
    "-nonews"
  ),
  collapse = " "
) %>% 
  sprintf(
    sysparam1, sysparam2,
    config_path,
    autoexec_path,
    wd_path,
    wd_path
)

I moved both the autoexec and sysparm options to the new autoexec file, but you're right that I could leave the sysparm in my sasopts. I still have to create the temporary autoexec, although it now just has %include "/serverpath/autoexec.sas"; in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants