SAS stored process to a web service link - web-services

I have created a SAS stored process and I need to attach it to a web service link which I intend to use it as an input in a python program .
I would really appreciate if I could get help in creating a web service from a SAS stored process .
Thank you,
Nishant

You need to create a Stored Process in SAS Management Console, and assign it to use the Stored Process Server (not Workspace Server). Ensure it has the 'streaming output' checkbox selected.
The SAS code behind this Stored Process should then send the output (that you wish to receive from your python program) to the _webout fileref, eg:
data _null_;
file _webout;
put 'Hello python!';
run;
The %stpbegin and %stpend macros should NOT be used.
To reference the Stored Process just call the URL with your Stored Process name & path in the _program parameter, as follows:
http://[yourMachineName]:8080/SASStoredProcess/do?_PROGRAM=/Your/MetadataPath/YourSTPName

Easiest is to use the SAS Stored Process Web App. It allows you to call a stored process via URL. You should read (http://support.sas.com/documentation/cdl/en/stpug/68399/HTML/default/viewer.htm#n0mbwll43n6sw3n1jhcfnx51i8ze.htm).
From there, use the Python requests library.

Related

Executing webjobs via SQL server Stored Procedure

I have a very simple C# console exe. My code deletes a blob from a particular blob storage. It takes a couple of command-line arguments - container name & blob name and deletes the blob whenever triggered.
Now, I want to schedule this exe as a webjob.
I have a couple of questions -
How can I manually trigger this webjob since it takes command line arguments?
Is there any way that I can trigger this webjob via a SQL server stored procedure?
You can use the stored procedure to send http requests to fulfill your needs.
Steps
You can use the Kudu Webjob API to invoke your function.
Create HttpRequest Method in sql server.
Related post
How can I make HTTP request from SQL server?

SOAP request - SAS CI

Am trying to invoke campaign via SOAP request ,which is suppose to insert data into data warehouse,but it's not happening.am using DS2 code for it
When I try run the same campaign in test mode in SAS CI it's happening
I want the log that gets generated via SOAP request.can anyone let me know the path for the same.
Thanks in advance.
You need to check the log files on your application & mid-tier servers. Search the log files for the time you ran your request.
Start by checking the ObjectSpawner log to see if any connections were made the SAS environment at that time: ex. C:\SASHome\Lev1\ObjectSpawner\Logs

Determining Server Context (Workspace Server vs Stored Process Server)

I'd like to conditionally execute code depending on whether I'm in a Workspace or Stored Process server context.
I could do this by testing the existence of an automatic STP variable, eg _metaperson, but this wouldn't be very robust.
Assuming I already have a metadata connection, how best to check my server type?
Bulletproof way would be to create a macro variable that is initialised by the autoexec or config in the required server context.
Of course this would only work if you have access and permission to modify files stored in sas configuration folder.
Hurrah - there is, in fact, an automatic variable that does just this - sysprocessmode (available since 9.4)
Extract from documentation:
SYSPROCESSMODE is a read-only automatic macro variable, which contains
the name of the current SAS session run mode or server type, such as
the following:
SAS DMS Session
SAS Batch Mode
SAS Line Mode
SAS/CONNECT Session
SAS Share Server
SAS IntrNet Server
SAS Workspace Server
SAS Pooled Workspace Server
SAS Stored Process Server
SAS OLAP Server
SAS Table Server
SAS Metadata Server
Being an automatic variable, it is of course read only:
The stored process server will preset the _PROGRAM macro variable with the program that is running. I do not know if this macro variable is read-only in the STP execution context.
But as you say, a program in the workspace context could set a _PROGRAM macro variable.
For workspace sessions look for _CLIENTAPP macro variable.
I am unaware of a function to call or immutable system option that can be examined. Try PROC OPTIONS in both contexts and see what pops out. An OBJECTSERVERPARMS value, if reported, is a list of name=value pairs. One of them would be server= and may differentiate.

how can I use R Studio data in shinyServer

In my local machine I use RStudio + Shiny to work properly.
Now that I have Shiny-Server installed on linux, but I do not know the Data generated by RStudiom.
how can I get Shiny-Server to read it?
Do not know what keyword query?
Thanks
Importing data in the server
As I see it, there are two ways to supply data in this situation.
The first one is to upload the data to the server where your shiny-apps are hosted. This can be done via ssh (wget) or something like FileZilla. You can put your data in the same folder as the app and then access them with relative paths. For example if you have
- app-folder
- app.R
- data.rds
- more_data.csv
You can use readRDS("data.rds") or readr::read_csv2("more_data.csv") in app.R to use the data in the app.
The second option is to use fileInput inside your app. This will give you the option to upload data from your local machine in the GUI. This data will then be put onto the server temporarilly. See ?shiny::fileInput.
Exporting data from RStudio
There are numerous ways to do this. You can use save to write your whole workspace to disk. If you just want to save single objects, saveRDS is quite handy. If you want to save datasets (for example data.frames) you can also use readr::write_csv or similar functions.

Cant read in .csv file

I am opening a new program in SAS Enterprise Guide using file -> new -> program.
Now I would like to a load .csv file from my desktop using the following code:
proc import datafile="C:\Users\M.van.der.Peet\Desktop\test.csv"
out=shoes
dbms=csv
replace;
getnames=no;
run;
proc print;
run;
When I run this I get the following error however:
ERROR: Physical file does not exist, C:\Users\M.van.der.Peet\Desktop\test.csv.
But the file is there :). Any thoughts on how I get a better understanding of why this is not working? Is there an ls() like function to see which files are stored in a dir?
If your EG session is connected to a remote SAS server (such as a Linux server) your code will not work.
Basically, when you press submit in EG, it uploads the code to the SAS server, executes the code, and downloads the results and log to the EG client. Since the remote server cannot see files on your local C: drive, you will get an error if you try to read a file on C:.
You can upload the file to the remote server, and it will work. Or if you look at the EG tasks in the menus, I'm sure there is an IMPORT task or similar name which would work. The task works by uploading the input file for you before the SAS code is submitted. I don't use the menus, so can't give you the details.
Enterprise Guide is typically installed on UNIX/Linux Server. You have to FTP the file i.e. upload the file using a FTP client like WinSCP or UltrEdit from Windows to a location on UNIX. Then you have to provide that path on your program.