BookmarkSubscribeRSS Feed

GitHub + SAS Studio Integration in SAS Viya for Learners 4 (VFL4)

Started Thursday by
Modified Thursday by
Views 85

I’ll flash the alert again:

 

Not-so-breaking news: GitHub is an industry standard for developers + coders!

 

Following the heels of my SAS Community article on GitHub + Jupyter Integration in SAS Viya for Learners 4 (VFL4) , this episode focuses on how easily you can incorporate GitHub into SAS Studio in Viya for Learners 4.  Because sharing and collaborating with code across various cloud-deployments is a skill that all coders should master.

 

Before launching right into it, I’ll set the stage a bit more:

  • Don’t know what the heck SAS Viya for Learners 4 is?  Well, it’s one of the primary tools for teaching and learning for all things academic.  Find more information here.
  • And if you’re already a committed SAS VFL3.5 user and want reasons to switch to our latest-and-greatest offering of SAS Viya for academics, then let me convince you in this SAS Communities Post.
  • Finally, I’ll assume some basic level of familiarity with GitHub in this post (like how to set-up and account and general navigation in GitHub). However, if you’re completely new to GitHub, start with this great video and setup an account today.

 

The rest of the article flows as follows:

  • Part 1 assumes that you already know how to use GitHub and shows you how to connect to an existing GitHub repo and then push SAS Studio code changes to GitHub.
  • Part 2 takes a step back and helps you find your access token key. This section is useful if you’re still coming up to speed with all things GitHub.

 

And, yes, I’ll steal a LOT of the language from my earlier post 😊

 

Part I: You already know Git… and you just need to connect SAS Studio in VFL4

 

To guide the narrative in Part 1, I’ll show you an example of where I want to connect SAS Studio to a GitHub repo that contains a SAS data set that I want to summarize.  The data come from the American Community Survey (ACS) and track the labor supply of prime-aged women (i.e., those aged 25-54) before, during, and after COVID.

Before embarking on that quest, more fine print is needed.  And it’s this: please don’t follow the steps as exactly outlined below. Why? Because it’s my file… and my edits. Create your own – or you’ll likely get access errors. Seriously 😊

 

Disclaimers aside, who is ready to learn?  Let’s go!

  • Step 1 is simply to get into SAS Studio in SAS Viya for Learners 4 (though this likely works in commercial environments too). Find – and click – the Applications menu in the upper-left corner.  It’s also known lovingly as the hamburger menu:

 

LGroves_0-1718893421914.png

 

  • Next, select Develop Code and Flows:

 

LGroves_1-1718893421918.png

 

  • And welcome to SAS Studio! Seriously, it says that here:

 

LGroves_2-1718893421926.png

 

  • And SAS Studio is a rich environment indeed. If it’s your first time in SAS Studio, then please take a little time to explore the application interface.  When you’ve got a basic lay of the land, click the Git Repositories button on the left side pane, here:

 

LGroves_3-1718893421930.png

 

 

LGroves_4-1718893421932.png

 

  • You should then see the Clone a Repository window:

 

LGroves_5-1718893421934.png

 

  • Easy peasy, thus far.  For Repository, I’ll paste https://github.com/lincolngroves/RandomData-RandomThoughts.git
  • For Server location, I’ll create a new folder within my home directory to store the file that I’ll pull from GitHub and then new one that I’ll create.  The process starts by clicking the Specify the server folder for the new repository button, found here:

 

LGroves_6-1718893421936.png

 

  • Another window appears.  Here you can Select a Folder within your system.  I’ll drill into Files >> Home and then select the New folder icon, with the Home folder selected:

 

LGroves_7-1718893421938.png

 

  • For the new folder, I’ll choose something relevant, like LaborSupply and then click OK:

 

LGroves_8-1718893421939.png

 

  • On the next window, select your new folder – mine is LaborSupply – and then click OK again. My example:

 

LGroves_9-1718893421941.png

 

  • For our last trick in this section, we’ll specify a Profile.  If this is your first time, you’ll likely need to Create new profile:

 

LGroves_10-1718893421946.png

 

  • After selecting Create new, the following options in the Add a Profile window appear:

 

LGroves_11-1718893421947.png

 

  • Enter your information.  As indicated by the red stars, you need a Profile name, a User name, and an Email.  Those items are typically associated with your GitHub account.  I’ll show you mine, because it’s public knowledge:

 

LGroves_12-1718893421950.png

 

  • The biggest item – one which I won’t show you – is the Password. Because passwords are secret. Like top secret.  And know that SAS is looking for a Personal Access Token, which allows you to write to that GitHub folder.  Please see Part 2 – if you need help accessing that very important item… because you won’t be able to push your changes to GitHub without it.  You can pull data but not push changes to Github… sorry.
  • Now I’ve got the required info.  And will select Clone:

 

LGroves_13-1718893421953.png

 

  • I should see my LaborSupply folder under Git Repositories:

 

LGroves_14-1718893421963.png

 

  • But, to see the actual files, go to Explorer then navigate to Files >> Home and expand LaborSupply:

 

LGroves_15-1718893421965.png

 

  • Ah files.  The file that we want to explore is acs_2015_2022.sas7bdat.  I’ll start by opening a new SAS Program.  One way to do that is to click on the + button to the right of the LaborSupply depot and then select SAS program.  That’s actually two clicks, but they’re kind of on top of each other:

 

LGroves_16-1718893421971.png

 

  • A blank page awaits.  I’m going to show a super simple example here of a program.  Normally, I’d build it out a LOT more, but this will show you how to get things started.
  • I first begin with a SAS program preamble, such as:

 

 

*--------------------------------------------------------------------------------------------------------*
|               	                 SAS Communities Post                      	        			 	 |
|	                 	SAS Studio + GitHub Integrations using ACS Data                       			 |
*--------------------------------------------------------------------------------------------------------*;
libname 	ipums "~/LaborSupply";
options 	orientation=landscape mlogic symbolgen pageno=1 error=3;

title1 		"SAS Communities Post";
title2 		"SAS Studio + GitHub Integrations using ACS Data";

 

 

  • A good first place to start with any data set is to use the Characterize Data Task in SAS Studio to summarize the data.  I did just that and – with a couple of modifications – it produced this code:

 

 

************************************************  Summarize the Data;
ods noproctitle;

/*** Analyze categorical variables ***/
title "Frequencies for Categorical Variables";

proc freq data=IPUMS.ACS_2015_2022;
	tables State_Name YearQuarter Race_Ethnic EDUC_LTD Child_Status / 
		plots=(freqplot);
run;

/*** Analyze numeric variables ***/
title "Descriptive Statistics for Numeric Variables";

proc means data=IPUMS.ACS_2015_2022 n nmiss min mean median max std;
	var Unemp in_LF WTFINL;
run;

title;

proc univariate data=IPUMS.ACS_2015_2022 noprint;
	histogram Unemp in_LF WTFINL;
run;

 

  • My final trick in this section is to save the file as SAS Studio + GitHub Integrations using ACS Data.  I’ll find, and click, the Save as button, found here:

 

LGroves_19-1718893421983.png

 

  • Within the Save As window, I’ll want to navigate to my LaborSupply folder. I can then Name the file SAS Studio + GitHub Integrations using ACS Data and then click Save:

 

LGroves_20-1718893421987.png

 

  • Check for this note in the lower right corner:

 

LGroves_21-1718893421988.png

 

  • That’s some good news.  And we could keep coding.  And coding.  And coding.  But what I really want to do is show you how to take this file and push the changes up to GitHub.  Because all changes up until this point are local changes only.  You haven’t pushed – or changed – the file stored on the GitHub site – aka the public site.  And you’ll definitely want to do that if you are (1) collaborating with others or (2) using different coding environments (i.e., 2 different VFL deployments).
  • So, let’s return to the Git Repositories by clicking the icon on the left and then selecting the LaborSupply folder (option 1).  Or, more simply, you can click the LaborSupply tab, which is likely still open (option 2).  Either way, get here and you should see some Unstaged Changes:

 

LGroves_22-1718893421995.png

 

  • Next, I’ll right click on SAS Studio + GitHub Integrations using ACS Data and then choose Stage selected:

 

LGroves_23-1718893421996.png

 

  • Progress! In the Staged Changes section, I can now Enter a commit comment.  I’ll put Version 1.0 of the GitHub + SAS Studio illustration and then click Commit:

 

LGroves_24-1718893421998.png

 

  • We’ve made a commitment.  And that’s important.  But, we actually haven’t pushed the changes to GitHub.  And, honestly, that’s kind of the most important step here.  
  • Pushing is just one click away.  Find the Push master button.  Click it:

 

LGroves_25-1718893422006.png

 

  • If your permissions are setup properly, you should see that the changes are now available in GitHub. Yay! My proof:

 

LGroves_26-1718893422010.png

 

  • Woot!  The next step would be to continue developing the SAS Studio + GitHub Integrations using ACS Data program and then committing changes when you’re at a good commitment point. 
  • Finally, unlike my Jupyter example, SAS Studio is a permanent environment, meaning that local changes are retained after the session ends.  So, you can keep saving locally, session after session – and then just push to GitHub when you have a more finished product.
  • Happy Git’n!

 

Part II: You (kind of) know Git, but need help setting up the personal access token

 

Alright, perhaps you’re only familiar with GitHub in the sense that it’s a great tool for learning – and you use it only when you need to pull files down from GitHub to use in VFL.  That’s cool.  I was there.  And that was me like 10 minutes ago (nothing prompts learning like writing a SAS Communities article!).

 

This section will walk you through how you can set up a personal access token, which will allow you to push changes to files + data + more to GitHub for everyone to examine.  And it’s a very powerful tool indeed.  Let’s get started:

 

LGroves_27-1718893422028.png

 

  • Next, find the Settings section:

 

LGroves_28-1718893422031.png

 

  • Look at all those settings available.  Whoa!  Scroll down and find < > Developer settings on the left side:

 

LGroves_29-1718893422033.png

 

  •  Still on that left-hand side, expand on Personal access tokens.  Select Tokens (classic):

 

LGroves_30-1718893422036.png

 

  • Click on Generate new token >> Generate new token (classic):

 

LGroves_31-1718893422040.png

 

  • While you can choose a variety of options for your token, I’m keeping it simply in this example. Moreover, for security purposes, I’ll choose a token that expires after a day so that you’re not tempted to use it 😊
  • Under Note, I’ll put VFL4 Upload Illustration.  Choose a longer Expiration, but I’ll set mine to a day.  Those two steps:

 

LGroves_32-1718893422043.png

 

  • Under Select scopes, select only repo. This keeps it simple:
LGroves_33-1718893422045.png

 

  • Finally, scroll all the way to the bottom and then click Generate token:

 

LGroves_34-1718893422049.png

 

  • The token is now created!  Here’s my example:

 

LGroves_35-1718893422051.png

 

  • Remember, that’s my token – and it no longer works 😊  Additionally, please read that important note in blue: Make sure to copy your personal access token now. You won’t be able to see it again!  Seriously, it’s gone.
  • Now you can use that personal access token with your username in your Git credentials, all the way back in this step from Part 1:

 

LGroves_36-1718893422053.png

 

Again, happy Git’n!

Version history
Last update:
Thursday
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags