Last active
February 23, 2018 01:00
-
-
Save royalsouvenir/ca0a76628186643ed30a172995472e57 to your computer and use it in GitHub Desktop.
Grab all Administration Topics for SAS Global Forum 2018 as a response to https://communities.sas.com/t5/SAS-Global-Forum-2018/SAS-Global-Forum-Session-Catalog-Filter-Feedback/gpm-p/439186#M69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Executes a search against SGF 2018 sessions and inserts the delta of that data into a table. | |
* | |
* :author: Cameron Lawson <https://seleritysas.com> | |
* :param topic: The SGF Topic to Search. | |
* :type topic: Character | |
* :return: SAS Dataset work.sgf_sessions | |
* :rtype: SAS Dataset | |
* :example: `%sgfAdminSessions(topic=%nrquote(Administration: Cloud)); | |
*/ | |
%macro sgfAdminSessions(topic); | |
%let _url = %nrquote(http://www.sasgfsessioncatalog.com/Home/getFilterData); | |
%let _stype = %nrstr(Topic); | |
%let _sval = %str(&topic.); | |
%let _sstr = %sysfunc(urlencode(&_stype.||&_sval.^)); | |
%let url = %nrquote(&_url.&_sstr); | |
%put &=url; | |
filename resp temp; | |
proc http | |
method='post' | |
url="&_url." | |
in="data=&_sstr." | |
out=resp | |
; | |
run; | |
libname sgf json fileref=resp; | |
proc copy in=sgf out=work; | |
select root; | |
run; | |
libname sgf clear; | |
/* A bit of data cleaning */ | |
data work.root; | |
set work.root; | |
if _n_ = 1 then do; | |
prx = prxparse("s/<.*?>//"); | |
end; | |
retain prx; | |
array str title description; | |
do over str; | |
/*There are other unicode characters, I'm lazy and got bored going through them.*/ | |
str = tranwrd(str,"Â",""); | |
end; | |
objective = urldecode(prxchange(prx,-1,objective)); | |
drop prx; | |
run; | |
%if %sysfunc(EXIST(WORK.SGF_SESSIONS)) %then %do; | |
proc sql; | |
delete from work.root where id in (select id from work.sgf_sessions); | |
insert into work.sgf_sessions | |
select * from work.root | |
; | |
quit; | |
proc datasets lib=work nolist nodetails nowarn; | |
delete root; | |
quit; | |
%end; | |
%else %do; | |
data work.sgf_sessions; | |
set work.root; | |
run; | |
%end; | |
%mend; | |
proc datasets lib=work nolist nodetails nowarn; | |
delete sgf_sessions; | |
quit; | |
%sgfAdminSessions(topic=%nrquote(Administration: Architecture)); | |
%sgfAdminSessions(topic=%nrquote(Administration: Cloud)); | |
%sgfAdminSessions(topic=%nrquote(Administration: Deployment)); | |
%sgfAdminSessions(topic=%nrquote(Administration: SAS Administration)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment