BookmarkSubscribeRSS Feed
Vimal08
Obsidian | Level 7

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!

 

6 REPLIES 6
Quentin
Super User

@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;

 

AllanBowe
Barite | Level 11

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

/Allan
MacroCore library for app developers
Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Vimal08
Obsidian | Level 7

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.

 

Vimal08_0-1664265061525.jpeg

 

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.

 

Vimal08_1-1664265716068.png

 

Thanks!!

ChrisHemedinger
Community Manager

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.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
AllanBowe
Barite | Level 11

@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?

/Allan
MacroCore library for app developers
Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
ChrisHemedinger
Community Manager

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);

 

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

Join the 2025 SAS Hackathon!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3362 views
  • 6 likes
  • 4 in conversation