Hi Team,
We have our SAS codes on GITHUB in one of the repositories, and we have already figured out how to clone the repository, and pushing, pulling and stashing the SAS files in studio and EG. But we are trying to figure out a way, where we can execute the SAS codes from GIT itself, without placing the code in any of client SAS server. Please help us to figure out the same.
Your help will be highly appreciated!! Thanks!
@AllanBowe shared an example over on SO https://stackoverflow.com/questions/48400210/include-sas-file-from-github-url
filename bizarro url
"https://raw.githubusercontent.com/allanbowe/BizarroBall/master/bizarroball.sas";
%inc bizarro;
I would definitely advise against this approach in production, as it will require very careful management when it comes to promotions / merging etc. Cloning the repo to your target machine, and pulling as necessary, is far preferable. Or, building your SAS jobs & services from the target branch, taking GIT out of the picture completely.
But anyways - beyond the approach that @Quentin references, you can also use the `sasjs run` command to execute code from a GIT repo (with the caveat that it will only work where authentication is not required).
Docs: https://cli.sasjs.io/run/#using-github-urls
Hi @Quentin and @AllanBowe,
Thanks for the quick response!! we have tried executing the SAS code from SAS Studio, but getting an error which says "Invalid reply received from the HTTP server". Please help us to resolve this error.
Also, we have tried installing NVM to execute the commands to run SAS code from GIT using sasjs/cli, but there also we are getting an error. Below is the snapshot of the error, please help me to resolve this issue as well.
Thanks!!
Does your environment have access to the Internet or does it require a proxy server? See how to check this (and correct with PROXY options) in this article.
@Vimal08 - we were unable to replicate that issue, however we have decided to just deprecate that function entirely (it was a check on install to ensure the user has the correct version of Node, ie LTS).
We've now updated the utils, adapter and CLI repos. Can you install the latest version (3.19.5 +) and try again?
If your code is a system of files (macros, data files, multiple code files), then I recommend using the git_clone function in SAS (gitfn_clone in 9.4m6, then aliased to git_clone in later releases) to clone the repo to a temp space and use that as a base for your %include statements. Example:
options dlcreatedir;
%let repopath=%sysfunc(getoption(WORK))/wordle-sas;
libname repo "&repopath.";
data _null_;
rc = gitfn_clone(
"https://github.com/sascommunities/wordle-sas",
"&repoPath."
);
put 'Git repo cloned ' rc=;
run;
%include "&repopath./wordle-sas.sas";
/* start a game and submit first guess */
%startGame;
%guess(adieu);
Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!
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.