Is it possible to perform SAS VA report distribution via PROC HTTP ?
We have SAS 9.5M6 with SAS Visual Analytics 7.5.
Normally for report distribution , we schedule report distribution from Report designer and it only support time based schedule.
I was exploring option to perform report distribution via some code /script . So when data refresh is finished or any custom condition is met, script / PROC HTTP code runs and report is distributed.
I tried few things using proc http but not working.
I extracted CURL command using browser developer tool which has long header information .
Challenging is to pass three parameters in proc HTTP
1) referel URL :
2) Cookie : Generating cookie and passing to next url
3) binary data : very huge information pass by browser to SAS for report distribution (Not sure how much data is required to pass)
Below is huge cURL command extracted from Browser developer tool . Specially binary-data that browser pass to SAS Webserver is very huge.
curl 'https://midtier@domain.com:8343/SASVisualAnalyticsTransport/sasui/vaScheduler/flow?javascriptTimezoneOffsetNewYears=300&javascriptTimezoneOffsetJuly=240&operation=runnow' \
-H 'Connection: keep-alive' \
-H 'Accept: application/json, text/javascript, */*; q=0.01' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Accept-Language: en' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36' \
-H 'Content-Type: application/json' \
-H 'Origin: https://midtier@domain.com:8343' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Referer: https://midtier@domain.com:8343/SASVisualAnalyticsDesigner/VisualAnalyticsDesigner.jsp?launchedFromAppSwitcher=true&useTransitionSplash=true' \
-H 'Cookie: 45f55273f051bd8b0ec7fac404e76b35_Cluster12=DAE038C7C9249DD71F790729A4151D74.45f55273f051bd8b0ec7fac404e76b35_SASServer12_1' \
--data-binary '{"@type":"flow","idDataBinding":"A5DDG8HK.BW00000A","creationDateDataBinding":1604080633000,"modifiedDateDataBinding":1604081379000,"descriptionDataBinding":"","locationDataBinding":"/System/Applications/SAS Visual Analytics/ScheduledDistribution/Pallav Lodhia","locationIdDataBinding":"A5DDG8HK.AA0000ZJ","iconNameDataBinding":"GIF_16/JobFlow_deployed.gif","displayOnlyDataBinding":false,"nameDataBinding":"user1_WarrantyAnalysis_1604080633288","schedulerDataBinding":{"@type":"schedulerServer","idDataBinding":"A5DDG8HK.AY0000RU","descriptionDataBinding":"","iconNameDataBinding":"GIF_16/Server.gif","displayOnlyDataBinding":false,"nameDataBinding":"SAS Distributed In-Process Services Scheduling Server","classidDataBinding":"c8b4baf0-5f9f-488e-ba76-1201e1e81aef","typeDataBinding":"SAS PIP Services","hostDataBinding":"midtier@domain.com","portDataBinding":"0","subflowSupportedDataBinding":true,"timeeventSupportedDataBinding":true,"fileeventSupportedDataBinding":true,"fileeventSupportedAsTriggersDataBinding":true,"enterpriseLevelSupportOfFileEventsDataBinding":false,"multiTriggersSupportedDataBinding":false,"advanceFlowCompletionCriteriaSupportedDataBinding":true,"emailNotificationSupportedDataBinding":true,"areQueuesDataBinding":false,"queueListDataBinding":[],"jobDefaultEmailNotificationSupportedDataBinding":true,"jobDefaultPrioritySupportedDataBinding":true,"jobDefaultEnvironmentVariablesSupportedDataBinding":false,"exclusiveExecutionSupportedDataBinding":true,"timezoneSupportedDataBinding":true,"limitedSkipsDataBinding":false,"basicSchedulerDataBinding":false,"classId":"c8b4baf0-5f9f-488e-ba76-1201e1e81aef","subflowSupported":false,"timeEventSupported":true,"fileEventSupported":true,"fileEventSupportedAsTriggers":true,"enterpriseLevelSupportOfFileEvents":true,"advanceFlowCompletionCriteriaSupported":true,"emailNotificationSupported":true,"exclusiveSupported":true,"jobDefaultEmailNotificationSupported":true,"jobDefaultPrioritySupported":true,"jobDefaultEnvironmentVariablesSupported":false,"timezoneSupported":true,"multiTriggersSupported":true,"orgateSupported":true,"consoleSupported":true,"basicScheduler":false,"host":"midtier@domain.com","port":"0","type":"SAS PIP Services","sslenabled":false,"id":"A5DDG8HK.AY0000RU","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/Server.gif","name":"SAS Distributed In-Process Services Scheduling Server","description":""},"availableTriggersDataBinding":[],"triggerTypeDataBinding":"RunNow","responsiblePartyDataBinding":"Pallav Lodhia","jobsDataBinding":[{"@type":"job","idDataBinding":"A5DDG8HK.BW000009","creationDateDataBinding":1604080620000,"modifiedDateDataBinding":1604080620000,"locationDataBinding":"/System/Applications/SAS Visual Analytics/ScheduledDistribution/Pallav Lodhia","locationIdDataBinding":"A5DDG8HK.AA0000ZJ","iconNameDataBinding":"GIF_16/Job_deployed.gif","displayOnlyDataBinding":false,"nameDataBinding":"WarrantyAnalysis","batchServerDataBinding":{"@type":"batchServer","idDataBinding":"A5DDG8HK.AY00000Q","descriptionDataBinding":"","iconNameDataBinding":"GIF_16/Server.gif","displayOnlyDataBinding":false,"nameDataBinding":"SASAppVA - Visual Analytics Scheduled Distribution","classidDataBinding":"0069e914-b58c-4094-a686-a87df433ec4b","typeDataBinding":2,"subTypeDataBinding":26,"operatingSystemDataBinding":1,"directoriesDataBinding":[{"@type":"directory","idDataBinding":"A5DDG8HK.BA000007","descriptionDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","iconNameDataBinding":"GIF_16/DeploymentDirectories.gif","displayOnlyDataBinding":false,"nameDataBinding":"Batch Jobs","pathDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","path":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","id":"A5DDG8HK.BA000007","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/DeploymentDirectories.gif","name":"Batch Jobs","description":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs"}],"workspaceNameDataBinding":"SASAppVA - Workspace Server","jclDirectoryDataBinding":"","hostDataBinding":"lcncqsasva01.domain-energy.com","operatingSystem":1,"classId":"0069e914-b58c-4094-a686-a87df433ec4b","directories":[{"@type":"directory","idDataBinding":"A5DDG8HK.BA000007","descriptionDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","iconNameDataBinding":"GIF_16/DeploymentDirectories.gif","displayOnlyDataBinding":false,"nameDataBinding":"Batch Jobs","pathDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","path":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","id":"A5DDG8HK.BA000007","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/DeploymentDirectories.gif","name":"Batch Jobs","description":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs"}],"jcldirectory":"","subType":26,"host":"lcncqsasva01.domain-energy.com","type":2,"id":"A5DDG8HK.AY00000Q","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/Server.gif","name":"SASAppVA - Visual Analytics Scheduled Distribution","description":""},"jobDataBinding":{"@type":"DisplayInfo","idDataBinding":"A5DDG8HK.BS00001F","displayOnlyDataBinding":false,"nameDataBinding":"WarrantyAnalysis","id":"A5DDG8HK.BS00001F","displayInformationOnly":false,"displayOnly":false,"name":"WarrantyAnalysis"},"commandLineDataBinding":"\"/sashome/M6_install/config/Lev1/VASchedDist/vascheddistbatch.sh\" -vad_args {\"jobOwner\":\"Pallav Lodhia\",\"reportPaths\":[\"/Products/SAS Visual Analytics/Samples/Warranty Analysis Sample\"],\"recipients\":[\"Pallav Lodhia\"],\"emailDetails\":{\"subject\":\"Warranty Analysis Sample\",\"addJobOwner\":true},\"specialOptions\":{\"notifyStart\":false,\"notifyEnd\":false},\"ownerLocale\":\"en_US\"} ","commandLineDerivedDataBinding":true,"jobPriorityDataBinding":-1,"responsiblePartyDataBinding":"Pallav Lodhia","subFlowDataBinding":false,"subFlowJobIdsDataBinding":[],"jobArgsDataBinding":"-vad_args {\"jobOwner\":\"Pallav Lodhia\",\"reportPaths\":[\"/Products/SAS Visual Analytics/Samples/Warranty Analysis Sample\"],\"recipients\":[\"Pallav Lodhia\"],\"emailDetails\":{\"subject\":\"Warranty Analysis Sample\",\"addJobOwner\":true},\"specialOptions\":{\"notifyStart\":false,\"notifyEnd\":false},\"ownerLocale\":\"en_US\"}","job":{"@type":"DisplayInfo","idDataBinding":"A5DDG8HK.BS00001F","displayOnlyDataBinding":false,"nameDataBinding":"WarrantyAnalysis","id":"A5DDG8HK.BS00001F","displayInformationOnly":false,"displayOnly":false,"name":"WarrantyAnalysis"},"uniqueName":"WarrantyAnalysisA5DDG8HK.BW000009","commandLineDerived":true,"commandLine":"\"/sashome/M6_install/config/Lev1/VASchedDist/vascheddistbatch.sh\" -vad_args {\"jobOwner\":\"Pallav Lodhia\",\"reportPaths\":[\"/Products/SAS Visual Analytics/Samples/Warranty Analysis Sample\"],\"recipients\":[\"Pallav Lodhia\"],\"emailDetails\":{\"subject\":\"Warranty Analysis Sample\",\"addJobOwner\":true},\"specialOptions\":{\"notifyStart\":false,\"notifyEnd\":false},\"ownerLocale\":\"en_US\"} ","rawCommandLine":"\"/sashome/M6_install/config/Lev1/VASchedDist/vascheddistbatch.sh\" -vad_args {\"jobOwner\":\"Pallav Lodhia\",\"reportPaths\":[\"/Products/SAS Visual Analytics/Samples/Warranty Analysis Sample\"],\"recipients\":[\"Pallav Lodhia\"],\"emailDetails\":{\"subject\":\"Warranty Analysis Sample\",\"addJobOwner\":true},\"specialOptions\":{\"notifyStart\":false,\"notifyEnd\":false},\"ownerLocale\":\"en_US\"} ","jobPriority":-1,"subflow":false,"subflowJobIDs":[],"jobArgs":"-vad_args {\"jobOwner\":\"Pallav Lodhia\",\"reportPaths\":[\"/Products/SAS Visual Analytics/Samples/Warranty Analysis Sample\"],\"recipients\":[\"Pallav Lodhia\"],\"emailDetails\":{\"subject\":\"Warranty Analysis Sample\",\"addJobOwner\":true},\"specialOptions\":{\"notifyStart\":false,\"notifyEnd\":false},\"ownerLocale\":\"en_US\"}","batchServer":{"@type":"batchServer","idDataBinding":"A5DDG8HK.AY00000Q","descriptionDataBinding":"","iconNameDataBinding":"GIF_16/Server.gif","displayOnlyDataBinding":false,"nameDataBinding":"SASAppVA - Visual Analytics Scheduled Distribution","classidDataBinding":"0069e914-b58c-4094-a686-a87df433ec4b","typeDataBinding":2,"subTypeDataBinding":26,"operatingSystemDataBinding":1,"directoriesDataBinding":[{"@type":"directory","idDataBinding":"A5DDG8HK.BA000007","descriptionDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","iconNameDataBinding":"GIF_16/DeploymentDirectories.gif","displayOnlyDataBinding":false,"nameDataBinding":"Batch Jobs","pathDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","path":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","id":"A5DDG8HK.BA000007","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/DeploymentDirectories.gif","name":"Batch Jobs","description":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs"}],"workspaceNameDataBinding":"SASAppVA - Workspace Server","jclDirectoryDataBinding":"","hostDataBinding":"lcncqsasva01.domain-energy.com","operatingSystem":1,"classId":"0069e914-b58c-4094-a686-a87df433ec4b","directories":[{"@type":"directory","idDataBinding":"A5DDG8HK.BA000007","descriptionDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","iconNameDataBinding":"GIF_16/DeploymentDirectories.gif","displayOnlyDataBinding":false,"nameDataBinding":"Batch Jobs","pathDataBinding":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","path":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs","id":"A5DDG8HK.BA000007","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/DeploymentDirectories.gif","name":"Batch Jobs","description":"/sashome/M6_install/config/Lev1/SASAppVA/SASEnvironment/SASCode/Jobs"}],"jcldirectory":"","subType":26,"host":"lcncqsasva01.domain-energy.com","type":2,"id":"A5DDG8HK.AY00000Q","displayInformationOnly":false,"displayOnly":false,"iconName":"GIF_16/Server.gif","name":"SASAppVA - Visual Analytics Scheduled Distribution","description":""},"batchServerType":2,"batchServerSubtype":26,"type":"JOB","id":"A5DDG8HK.BW000009","displayInformationOnly":false,"displayOnly":false,"locationId":"A5DDG8HK.AA0000ZJ","iconName":"GIF_16/Job_deployed.gif","name":"WarrantyAnalysis","location":"/System/Applications/SAS Visual Analytics/ScheduledDistribution/Pallav Lodhia"}],"jobDependenciesDataBinding":[],"submittedDataBinding":true,"flowDefinitionIdDataBinding":"F1603380697241","scheduledUserIdDataBinding":"Anonymous","scheduleIdDataBinding":0,"emailNotificationDataBinding":-1,"completionLevelDataBinding":1,"completionSelectedJobNamesDataBinding":[],"endBehaviorDataBinding":1,"exitcodeBehaviorDataBinding":2,"exclusiveDataBinding":false,"saveLayoutDataBinding":false,"jobDefaultEmailNotificationDataBinding":-1,"jobDefaultPriorityDataBinding":-1,"jobDefaultEnvironmentVariablesDataBinding":"","jobDefaultExceptionHandlersDataBinding":"","notifyEmail":false,"scheduleDefinitionId":"F1603380697241","scheduleID":0,"jobDefaultNotifyEmail":false,"flowSubmitted":true,"scheduledUser":"Anonymous","dirty":true,"displayInformationOnly":false}' \
--compressed
Here few things I tried but not sure how cookie and binrary data to pass in proc http.
%macro echofile(file);
data _null_;
infile &file;
input;
put _infile_;
run;
%mend;
%macro check_return(code,expected);
%if &code ne &expected %then %do;
%put ERROR: Expected &expected, but received &code;
%abort;
%end;
%mend;
filename input TEMP;
filename resp TEMP;
filename headers TEMP;
data _null__;
file input recfm=f lrecl=1;
put "username=&username.%nrstr(&password)=&pwd";
run;
/* URL to get SAS Ticket */
proc http
method="POST"
url="https://midtier@domain.com:8343/SASLogon/v1/tickets"
in=input
headerout=headers
out=resp
HEADEROUT_OVERWRITE;
run;
%echofile(headers);
%echofile(resp);
%global hcode;
%global hmessage;
%global location;
data x;
infile headers scanover truncover;
input @'HTTP/1.1' code 4.
message $255.
@'Location:' loc $255.;
call symputx('hcode',code);
call symput('hmessage',trim(message));
call symput('location',trim(loc));
run;
%put &hcode ;
%put &hmessage;
%put &location;
data _x_;
file input recfm=f lrecl=1;
put "username=&username.%nrstr(&password)=&pwd";
run;
/*%let serviceurl=midtier@domain.com:8343/SASLogon/login?service=https%3A%2F%2Fmidtier@domain.com%3A8343%2FSASVisualAnalyticsDesigner%2Fj_spring_cas_security_check;*/
/*%let serviceurl=midtier@domain.com:8343/SASVisualAnalyticsDesigner/j_spring_cas_security_check;*/
%let serviceurl=midtier@domain.com:8343/SASVisualAnalyticsDesigner;
proc http
method="POST"
url="&location"
in="service=https://&serviceurl. "
headerout=headers
out=resp
HEADEROUT_OVERWRITE;
run;
%echofile(headers);
%echofile(resp);
/**********************************/
%global ticket;
data _null_;
infile resp;
input @;
call symput('ticket',trim(_infile_));
run;
%put &ticket;
/*url was extracted from browser developer tool copy CURL*/
proc http
url="https://midtier@domain.com:8343/SASVisualAnalyticsTransport/sasui/vaScheduler/flow?javascriptTimezoneOffsetNewYears=300%nrstr(&javascriptTimezoneOffsetJuly)=240%nrstr(&operation)=runnow"
/*url="https://midtier@domain.com:8343/SASVisualAnalyticsDesigner?ticket=&ticket."*/
/*url="https://midtier@domain.com:8343/SASVisualAnalyticsDesigner?ticket=&ticket."*/
/*url="https://midtier@domain.com:8343/SASVisualAnalyticsDesigner/j_spring_cas_security_check?ticket=&ticket."*/
in=input
out=resp
headerout=headers
;
run;
%echofile(headers);
%echofile(resp);
/* Trying to get Cookie */
%global cookie;
data cookie;
infile headers scanover truncover ;
input @'Set-Cookie:' cookie $255.;
cookie = scan(cookie,1,";");
call symput('cookie',trim(cookie));
run;
%put &cookie;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.