Hi @gwootton : Update - I still get the error message on the log file exceeding million characters. And also, Program errors out with the below message. Please request your help here if I am missed any. Updated the program with creationtimestamp as there was an error with attribute: created - No luck yet I believe, I am missing many things here. /* --- Begin Edit --- */
%let baseurl=http://sample.sas.com;
/* Set a per response limit. */
%let limit=100;
/* Init some files for the PROC HTTP output. */
filename headout temp;
filename resp temp;
filename init temp;
/* Define a table to store the user IDs we find. */
data work.users;
stop;
length id $ 255;
run;
%macro getusers;
/* Use our new token to search the users. */
proc http url="&baseurl/identities/users?start=0%nrstr(&limit)=&limit" oauth_bearer=sas_services out=init headerout=headout HEADEROUT_OVERWRITE;
headers "Accept"="application/json";
run;
data _null_;
rc=sleep(1,1);
run;
/* Read in the response. */
libname init;
libname init json fileref=init;
/* Put it into the dataset. */
proc sql;
insert into work.users select id from init.items;
quit;
/* Read the links to see if a "next" link exists. If so, set it to a macro variable "next" */
data _null_;
set init.links;
if rel="next" then call execute('%let next=%nrstr('||href||')');
run;
/* This loop will keep following the "next" link and appending records to the rules table until it has pulled all the rules defined. */
%do %while (%length(&next)>0);
/* Clear any existing users fileref and create one for this iteration. */
filename users;
filename users temp;
/* Call the "next" URL and output to the fileref. */
proc http url="&baseurl&next" oauth_bearer=sas_services out=users headerout=headout HEADEROUT_OVERWRITE;
headers "Accept"="application/json";
run;
data _null_;
rc=sleep(1,1);
run;
/* clear any existing users libref. */
libname users;
/* Read in the file ref. */
libname users json fileref=users;
%let next=;
/* If that output contains a next link, set it to the next variable, otherwise empty the next variable to end the do/while loop. */
data _null_;
set users.links;
if rel="next" then call execute('%let next=%nrstr('||href||')');
run;
/* Put the user IDs from this iteration into our data set. */
proc sql;
insert into work.users select id from users.items;
quit;
%end;
%mend;
/* Build the table of user IDs.*/
%getusers;
/* Create an empty table with the values we want. */
data userinfo;
stop;
length name id title state providerId creationTimeStamp $ 255 groups $2048;
run;
/* Write a macro that can be run for a given user ID to write the user's information into the table. */
%macro getuserinfo(id=);
filename userinfo;
filename userinfo temp;
filename grpinfo;
filename grpinfo temp;
proc http url="&baseurl/identities/users/&id" oauth_bearer=sas_services out=userinfo headerout=headout HEADEROUT_OVERWRITE;
headers "Accept"="application/json";
run;
data _null_;
rc=sleep(1,1);
run;
libname userinfo;
libname userinfo json fileref=userinfo;
proc http url="&baseurl/identities/users/&id/memberships" oauth_bearer=sas_services out=grpinfo headerout=headout HEADEROUT_OVERWRITE;
headers "Accept"="application/json";
run;
data _null_;
rc=sleep(1,1);
run;
libname grpinfo;
libname grpinfo json fileref=grpinfo;
data groups;
length groups $ 2048;
keep groups;
do until (last.id);
set grpinfo.items end=eof;
groups=catx(',',groups,id);
if eof then output;
end;
run;
proc sql noprint;
insert into work.userinfo select r.name,r.id,r.title,r.state,r.providerId,r.creationTimeStamp as created, g.groups from userinfo.root as r,work.groups as g ;
quit;
%mend;
/* Run that macro for each user ID. (obs=10 limits this to 10 responses for demo purposes.) */
data _null_ ;
set users;
str=catt('%getuserinfo(id=',id,');');
call execute(str);
run;
After above modified version, I am getting below error message Please request your help when you get a chance to look into this. Thank you
... View more