
11-22-2024
FriedEgg
SAS Employee
Member since
06-23-2011
- 1,340 Posts
- 27 Likes Given
- 32 Solutions
- 599 Likes Received
This widget could not be displayed.
-
Latest posts by FriedEgg
Subject Views Posted 5707 06-04-2021 12:11 PM 2151 01-19-2021 05:54 PM 2095 03-04-2020 11:40 AM 10846 01-09-2020 11:46 AM 10769 10-29-2019 11:07 AM 5941 09-24-2019 06:35 PM 2749 09-24-2019 11:02 AM 1346 09-02-2019 09:59 AM 9168 07-12-2019 11:09 AM 6355 07-12-2019 11:05 AM -
Activity Feed for FriedEgg
- Got a Like for Re: Encoding in proc export. 09-25-2024 04:32 PM
- Got a Like for Re: base64 encoding. 02-28-2024 08:40 AM
- Liked Re: macro parameter naming convention for yabwon. 01-08-2024 07:40 PM
- Liked Re: Generate global macro variables and then use them in a do loop for Reeza. 09-06-2023 01:40 PM
- Liked SAS Hackathon - Rapid Application Development a new tool from SAS in the Viya Ecosystem for Peter7. 03-16-2023 08:19 PM
- Got a Like for Re: SAS MACRO CATALOG: How to retrieve the source code of a compiled macro?. 09-02-2022 09:27 AM
- Got a Like for Re: How to get labels in proc means output dataset ?. 06-06-2022 02:00 AM
- Got a Like for How to get labels in proc means output dataset ?. 06-06-2022 01:58 AM
- Got a Like for Accessing/checking sort order in a dataset. 04-13-2022 10:03 AM
- Got a Like for Re: Question vlookup equivalent in SAS. 02-22-2022 06:01 AM
- Got a Like for Re: Encoding in proc export. 12-09-2021 08:44 AM
- Got a Like for Re: Regex prxparse question validating emails. 08-09-2021 01:46 PM
- Got a Like for Starting SAS in batch mode on windows. 06-30-2021 03:41 PM
- Got a Like for External Sources in SAS Studio Process Flow (.CDF) Files. 06-18-2021 07:24 AM
- Posted Re: Allow PROC SORT to output multiple datasets on SAS Product Suggestions. 06-04-2021 12:11 PM
- Got a Like for Add support for Markdown in SAS Studio Notes Detail. 02-03-2021 04:31 PM
- Got a Like for Re: Help converting a CURL command into PROC HTTP. 01-21-2021 05:44 PM
- Posted Re: Help converting a CURL command into PROC HTTP on Developers. 01-19-2021 05:54 PM
- Got a Like for Re: Select top 3 records for each id. 01-12-2021 12:56 PM
- Got a Like for External Sources in SAS Studio Process Flow (.CDF) Files. 11-13-2020 03:31 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 2 8 2 1 -
My Liked Posts
Subject Likes Posted 1 06-27-2013 09:24 AM 1 08-31-2011 11:45 AM 1 08-31-2011 10:56 AM 1 03-16-2012 08:42 PM 1 01-19-2021 05:54 PM -
My Library Contributions
Subject Likes Author Latest Post 0 0
06-04-2021
12:11 PM
With this following syntax, which looks almost identical to that shown by @yabwon you can accomplish the goal here, which is to avoid the extra IO from reading the sorted file to subsequently split into multiple datasets. This uses the experimental feature called "Output Data Step Views" which are incredibly powerful!
data cars_asia(where=(origin='Asia'))
cars_europe(where=(origin='Europe'))
cars_usa(where=(origin='USA'))
/
view=split_sort;
if 0 then set sashelp.cars;
set split_sort;
run;
proc sort data=sashelp.cars out=split_sort;
by msrp;
run;
1 data cars_asia(where=(origin='Asia'))
2 cars_europe(where=(origin='Europe'))
3 cars_usa(where=(origin='USA'))
4 /
5 view=split_sort;
6
7 if 0 then set sashelp.cars;
8 set split_sort;
9 run;
NOTE: DATA STEP view saved on file WORK.SPLIT_SORT.
NOTE: A stored DATA STEP view cannot run under a different operating system.
WARNING: The definition of an output DATA step view is an experimental feature in this release and is not intended for use in the
development of production applications.
10
11 proc sort data=sashelp.cars out=split_sort;
12 by msrp;
13 run;
NOTE: There were 428 observations read from the data set SASHELP.CARS.
NOTE: The data set WORK.SPLIT_SORT has 428 observations and 15 variables.
NOTE: The data set WORK.CARS_ASIA has 158 observations and 15 variables.
NOTE: The data set WORK.CARS_EUROPE has 123 observations and 15 variables.
NOTE: The data set WORK.CARS_USA has 147 observations and 15 variables.
... View more
01-19-2021
05:54 PM
1 Like
Steve,
Stepping through your attempts, you are close each time, but have simple mistakes we can easily address:
Attempt 1
When you use the IN= option with a quoted string, that data is posted, literally. So instead of sending the contents of the JSON file as you probably assume you are, you are actually just sending the web service the literal string "S:\My School QA\2021 Data Collection\SBD_Independents\FTP_Account_Creation\Requests\test1.json". The web service is expecting JSON data (because you specified the content_type), which this is not, so it responds with "Bad Request"
Instead you want to use the fileref you created when you wrote the json data to a file in the first data step ie:
filename json_in temp;
...
proc http
...
in=json_in /*no quotes*/
...
Attempt 2
Here you have a similar issue. You are using the FORM method on the IN= option. This helper method serializes the data you provide as a content-type such as application/x-www-form-urlencoded which your web service doesn't appear to support. The bad content type and data is why you receive the "Unprocessable Entity" error
You cannot use the FORM or MULTI helpers here in the IN= option as they are not valid for the type of data you want to POST
Attempt 3
This time the issue is slightly different. You are correctly trying to use the IN= option with string data equivalent to the JSON you want to post, however, you are using single quotes inside your JSON which is invalid syntax. You also should be including the CT= option with application/json
Instead, you want to use double quotes inside the JSON string as you have elsewhere in your post here:
proc http
...
in="{""notify"": true, ""emails"": [""croftie@tpg.co.au""], ""roleId"": 7, ""notifyFileAdded"": false}"
...
Attempt 4
This is essentially the same as attempt 1
Attempt 5
This is essentially the same as attempt 3, this is invalid JSON syntax so the web service cannot handle the data it receives.
Additional Information
Across all of your attempts you are also leaving out additional headers that could be important to your web service successfully responding to your request. Here is the most complete translation of your curl command in the HTTP Procedure
proc http
method="POST"
url="https://pluto.acara.edu.au/rest/folders/100/members"
ct="application/json"
oauth_bearer="&token" /* equivalent of headers "Authorization"="Bearer &token" */
in="{""notify"": true, ""emails"": [""croftie@tpg.co.au""], ""roleId"": 7, ""notifyFileAdded"": false}";
headers
"Accept"="application/json"
"X-Accellion-Version"="16";
debug level=3 NO_REQUEST_BODY NO_REQUEST_HEADERS OUTPUT_TEXT;
run;
... View more
03-04-2020
11:40 AM
@ChrisHemedinger and @CaseySmith how is this looking on the roadmap. I'm still waiting!
... View more
01-09-2020
11:46 AM
-u in cURL refers to user name/password for basic authentication. In the below, "sas.cli" would be the username and whatever is after the ":" would be the password.
In PROC HTTP you are using AUTH_NTLM instead of basic authentication. You would instead want to use AUTH_BASIC and WEB_USERNAME and WEB_PASSWORD options.
... View more
10-29-2019
11:07 AM
4 Likes
See the SASPy API Reference
https://sassoftware.github.io/saspy/api.html#saspy.SASsession.submit
Using %include as Tom suggests would presume that Jupyter, where you said you uploaded the code, is the same machine where you are submitting to SAS.
Two additional options you have:
1. Ditch the .sas file and put it's contents directly into your notebook as such:
results_dict = sas.submit(
"""
libname tera teradata server=teracop1 user=user pw=pw;
proc print data=tera.dsname (obs=10); run;
"""
)
2. Read the file contents into Python and then submit:
code = open('/users/myuserid.files/SAS_filename.sas').read()
results_dict = sas.submit(code)
... View more
09-24-2019
06:35 PM
I updated the example on GitHub to include an insert. Good luck.
https://github.com/FriedEgg/SAS-JDBC-Spring-Boot-Example
... View more
09-24-2019
11:02 AM
1 Like
@SergioSAS,
Below is an example of using the IDataSet interface, however, you may find it simpler to use JDBC instead.
import com.sas.iom.SAS.*; import com.sas.iom.SASIOMDefs.*; import com.sas.services.connection.*; import org.omg.CORBA.IntHolder; import org.omg.CORBA.StringHolder; import java.util.Arrays; public class SasOutputDataExample { public static void main(String... args) { ConnectionInterface cx = null; boolean failed = false; try { BridgeServer server = new BridgeServer(BridgeServer.CLSID_SAS, "sas.myhost.net", 8591); server.setEncryptionContent(BridgeServer.ENCRYPTION_CONTENT_ALL); server.setEncryptionAlgorithms(BridgeServer.ENCRYPTION_ALGORITHM_AES); server.setSecurityPackage(BridgeServer.SECURITY_PACKAGE_NEGOTIATE); server.setSecurityPackageList(BridgeServer.SECURITY_PACKAGE_LIST_DEFAULT); ManualConnectionFactoryConfiguration mconf = new ManualConnectionFactoryConfiguration(server); ConnectionFactoryManager manager = new ConnectionFactoryManager(); ConnectionFactoryInterface factory = manager.getFactory(mconf); SecurityPackageCredential cred = new SecurityPackageCredential(); cx = factory.getConnection(cred); } catch (ConnectionFactoryException err) { System.out.print(err.getMessage()); failed = true; } if (!failed) { IWorkspace workspace = IWorkspaceHelper.narrow(cx.getObject()); try { ILanguageService ls = workspace.LanguageService(); ls.Submit("data kids; set sashelp.class; run;"); ILibref libWork = workspace.DataService().UseLibref("work"); int flags = 0; StringHolder dataSetLabel = new StringHolder(); StringHolder dataSetType = new StringHolder(); DateTimeHolder dateCreated = new DateTimeHolder(); DateTimeHolder dateModified = new DateTimeHolder(); IntHolder recordLength = new IntHolder(); StringHolder compressionRoutine = new StringHolder(); IntHolder bookmarkLength = new IntHolder(); IntHolder logicalRecordCount = new IntHolder(); IntHolder physicalRecordCount = new IntHolder(); IntHolder attrs = new IntHolder(); IDataSet kids = libWork.OpenDataSet(flags, "kids", "", new String[]{"", "", ""}, dataSetLabel, dataSetType, dateCreated, dateModified, recordLength, compressionRoutine, bookmarkLength, logicalRecordCount, physicalRecordCount, attrs); int bindKey = 0; byte[] positionBookmark = new byte[]{}; int numberRowsToRead = 2; int rowsOffset = 0; VariableArray2dOfStringHolder characterValues = new VariableArray2dOfStringHolder(); VariableArray2dOfDoubleHolder numericValues = new VariableArray2dOfDoubleHolder(); VariableArray2dOfOctetHolder missingValues = new VariableArray2dOfOctetHolder(); OctetSeqHolder bookmarks = new OctetSeqHolder(); IntHolder status = new IntHolder(); kids.ReadRecords(flags, bindKey, positionBookmark, numberRowsToRead, rowsOffset, characterValues, numericValues, missingValues, bookmarks, status); for (int i = 0; i < numberRowsToRead; i++) { System.out.println(Arrays.toString(characterValues.value[i])); //character values are formatted } workspace.Close(); cx.close(); } catch (Exception err) { err.printStackTrace(); } } } }
This should then print the following to the console
[Alfred , M, Alfred , M, 14, 69, 112.5]
[Alice , F, Alice , F, 13, 56.5, 84]
IDataSet can also provide you with the metadata for the data set (i.e. Column Names, etc...)
... View more
09-02-2019
09:59 AM
Since you did not really qualify if you are interested in SAS Viya or SAS MVA and all the resources linked here are solely for Viya I will include the references for the latter. SAS® 9.4 Integration Technologies: Java Client Developer’s Guide https://documentation.sas.com/?docsetId=itechjcdg&docsetTarget=titlepage.htm&docsetVersion=9.4&locale=en SAS 9.4 BI API Documentation https://support.sas.com/rnd/javadoc/94/index.html
... View more
07-12-2019
11:09 AM
You may find this other post here helpful, and I do list there the minimum set of jar files to use the MVA driver for JDBC.
https://communities.sas.com/t5/Developers/How-can-I-use-SAS-9-4-jdbc-driver-in-the-Spring-boot-application/m-p/562719/highlight/true#M408
... View more
07-12-2019
11:05 AM
No thoughts immediately come to mind as to why your insert would have issues, but I do want to comment on you driver choice. Why use the MVA driver and define a library for SAS Share instead of using the SAS Share driver and connecting to that service directly?
... View more
06-26-2019
01:54 PM
1 Like
I hope that this is very close to 'next' on the roadmap!
... View more
06-26-2019
11:40 AM
Ok, the best next step I can think of is to try to get some additional logging, from when it hangs.
When you submit from the command line, I want you to specify the following command line option:
-LOGPARM "WRITE=IMMEDIATE"
In your SAS program, let's also increase the log verbosity by adding the following line of code at the top of the program
OPTIONS MLOGIC MLOGICNEST MPRINT MPRINTNEST MSGLEVEL=I;
In your HTTP Procedure call you use the debug statement. Let's also increase the level
PROC HTTP [...];
DEBUG LEVEL = 3;
RUN;
This all will produce a significantly larger log file, but specifically, what we care about most is if any additional log information is produced when the loop gets 'stuck' and the process appears to hang. As well as any potential logging produced when you, I assume, terminate the process.
... View more
06-24-2019
07:11 PM
You have three better options (in order of my opinion):
1) Define the libraries in metadata
2) Define the libraries in the jdbc connection. Something like the following
3) Put the libname into the application server autoexec
spring.datasource.connectionProperties: librefs="appdev 'C:\foo\bar\data'"
... View more
06-09-2019
01:37 AM
Using the polygon package for IML in place of PROC GINSIDE for calculating point intersection with multiple overlapping polygons
This notebook utilizes the polygon package for IML created by Rick Wicklin in order determine whether any of a set of points are inside a set of non-simple (intersecting) polygons. In this example we have two overlapping shapes and five points.
https://github.com/FriedEgg/Papers/blob/master/Random/Alternative%20to%20PROC%20GINSIDE%20for%20non-simple%20(intersecting)%20polygons.ipynb
... View more