Search code examples
githubsasincludesas-macro

%include .sas file from github url


I am trying to run a SAS file (which includes a %macro) directly from a github url. I found this post on blogs.sas.com that seemed to give me the solution. Unfortunately, I could not get it to work.

The .sas file I want to run is stored here on github.


What I gathered and modified from the blogs.sas post so far is:

filename _inbox "%sysfunc(getoption(work))/Macro H2_Piepho.sas";
proc http method="get" url="https://github.com/SchmidtPaul/HeritabilityScripts/blob/master/SAS/MACRO%20H2_Piepho.sas" 
out=_inbox;
run;
%Include _inbox;
filename _inbox clear;

But it gives me all kinds of errors:

8418  %Include _inbox;
8425 +<!DOCTYPE html>
      -
      180
WARNING: Apparent symbolic reference AMP not resolved.
WARNING: Apparent symbolic reference AMP not resolved.
WARNING: Apparent symbolic reference LT not resolved.
WARNING: Apparent symbolic reference GT not resolved.
WARNING: Apparent symbolic reference LT not resolved.
WARNING: Apparent symbolic reference GT not resolved.
WARNING: Apparent symbolic reference AMP not resolved.
WARNING: The quoted string currently being processed has become more than 262 characters long.
          You might have unbalanced quotation marks.
WARNING: The quoted string currently being processed has become more than 262 characters long.
          You might have unbalanced quotation marks.
ERROR: The token currently being processed is in an incomplete state. You might have an
       unbalanced single quoted string or a token exceeding the maximum length of 65535
       characters.
9661 +        <li><a
9661!+href="/SchmidtPaul/HeritabilityScripts/blame/7a18272000de0cfede86ae70a012ef581e95be3d/SAS
9661!+/MACRO%20H2_Piepho.sas" class="dropdown-item js-update-url-with-hash"
                                                                          ------
                                                                          49
9661!+id="js-view-git-blame">View git blame</a></li>
ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS
             release.  Inserting white space between a quoted string and the succeeding
             identifier is recommended.

9662 +          <li><a href="/SchmidtPaul/HeritabilityScripts/issues/new" class="dropdown-item"

------

49
9662!+ id="js-new-issue">Open new issue</a></li>
9671 +  <button type="button" data-facebox="#jump-to-line" data-facebox-class="linejump"
                                                         ----------------------
---------------
----------------------------------
                                                         49                            49
49
9671!+data-hotkey="l" class="d-none">Jump to Line</button>
WARNING: Apparent symbolic reference HELLIP not resolved.
WARNING: Apparent symbolic reference COPY not resolved.

NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS
             release.  Inserting white space between a quoted string and the succeeding
             identifier is recommended.

Thanks in advance for helping!


Solution

  • You can do this without the proc http by using the url access method of the filename statement, eg as follows:

    filename bizarro url 
      "https://raw.githubusercontent.com/allanbowe/BizarroBall/master/bizarroball.sas";
    %inc bizarro;