BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GPatel
Pyrite | Level 9
All:

I have SAS viya studio code that defines JSON files.
These files are being updated every day.

First time, I uploaded /copied manually but now
I would like to update these JSON files @
/public/json folder every day at 8:00am using either
SAS Viya Studio and Job VIYA execution components.

Proc export doesn’t work….

Proc export data=“/xyz/test/abc.json
…..
……
Run;

JSON FILEs provides autofill and autocomplete favors as opposed to use SAS data file from CAS library to be used for Drop down selections!!


How can I successfully set up
This actions / activities?
1 ACCEPTED SOLUTION

Accepted Solutions
GPatel
Pyrite | Level 9
Thanks to all, and specially to Dear Gwootton :

Upon updating SAS code to this....It worked like  a charm.

 
filename jobout filesrvc folderPath='/Public/Json';

data _null_;
set Unq_Circuit end=eof;
file jobout('test_Circuit.json') ;
if _n_=1 then put '[';
if not eof then delim=',';
put '{"Value":' Value ' "Text":' Text'}' delim ;
if eof then put ']';
run;
79 filename jobout filesrvc folderPath='/Public/Json';
80
81 data _null_;
82 set Unq_Circuit end=eof;
83 file jobout('test_Circuit.json') ;
84 if _n_=1 then put '[';
85 if not eof then delim=',';
86 put '{"Value":' Value ' "Text":' Text'}' delim ;
87 if eof then put ']';
88 run;
NOTE: The file library JOBOUT is:
Directory=/Public/Json,
Folder Identifier=4880eafd-d5e5-4ae6-ad0e-7e242d0b44d9,
Last Modified=10Jan2022:19:18:17
NOTE: The file JOBOUT('test_Circuit.json') is:
Filename=Test_Circuit.json,
URI path=/files/files/e2a8832f-03ce-46c8-ba5d-df61136c922c,
File Identifier=e2a8832f-03ce-46c8-ba5d-df61136c922c,
Document Type=file,Content Type=text/plain,
Content Disposition=inline;filename*=utf-8''Test_Circuit.json,
Encoding=UTF-8,Searchable=true,RECFM=V,
LRECL=32767,File Size (bytes)=0,
Last Modified=29Jul2022:19:50:59,
Create Time=29Jul2022:19:50:58
NOTE: A total of 351 records were written to the file library JOBOUT.
The minimum record length was 1.
The maximum record length was 29.
NOTE: 351 records were written to the file JOBOUT('test_Circuit.json').
The minimum record length was 1.
The maximum record length was 29.
NOTE: There were 349 observations read from the data set WORK.UNQ_CIRCUIT.
NOTE: DATA statement used (Total process time):
real time 0.66 seconds

View solution in original post

10 REPLIES 10
gwootton
SAS Super FREQ
If you're trying to create a JSON file in SAS, PROC JSON would be one method. You can use the JSON libname engine to read an existing JSON file.
--
Greg Wootton | Principal Systems Technical Support Engineer
GPatel
Pyrite | Level 9
Thanks for your response.

Creating JSON files is not an issue. These files are being updated every day.
The automation i.e. to upload/update these JSON files to public folder (SAS JOB EXECUTION) religiously is an issue.
Quentin
Super User

When you say update the json files, do you want to over-write them with a new version?  Or are you trying to insert records into an existing JSON file?  

 

Since JSON is a text file, I guess you could try to update it in place like any other text file.  But I think if I were doing it, I would probably read the current JSON file into a SAS dataset, do the updates to the SAS dataset, and then export the updated SAS dataset to JSON, over-writing to the original JSON file.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
GPatel
Pyrite | Level 9
Thanks for your attention and reply.

I have /public/json folder in VIYA JOB EXECUTION and
I want to update daily JSON files into that /public/json folder with automation by scheduled job !

My SAS code updates JSON files without any issue, but i want to upload / update them into /public/json folder with automation ( scheduling job to be run at certain time, so that it will update folder.


Tom
Super User Tom
Super User

It really doesn't sound like your question is about JSON at all, but just about moving files and scheduling jobs.

Which parts are you having trouble with?

 

Can you write the file to the place you need it?  Is the path on the machine where SAS is running?  Are you using VIYA or SAS?  Do you have permission to write it there?  Can you try writing some other file just to make sure?  

 

Can you schedule a job to run at a particular time of day?

 

What have you tried? How did it not do what you wanted?

 

gwootton
SAS Super FREQ
Is your meaning that /public/json is a folder in SAS Content (rather than a physical path)?

If so, the FILESVC access method can be used to read and write to the content server.

FILENAME Statement: FILESRVC Access Method
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/p0qapul7pyz9hmn0zfoefj0c278a...

More information on scheduling in Viya can be found here:

Tips for Scheduling Flows with SAS Viya Environment Manager
https://blogs.sas.com/content/sgf/2021/05/05/tips-for-scheduling-flows-with-sas-viya-environment-man...
--
Greg Wootton | Principal Systems Technical Support Engineer
GPatel
Pyrite | Level 9

Thanks for shedding some more lights on the topic.

The name of the game is to automate :

Upload daily updated JSON files    to /Public/JSON folder.

 

Below is SAS code to update JSON file everyday - I can schedule to run this job everyday.


data _null_;
set Unq_Circuit end=eof;
file "/../../../././gpatel/JSON/test_Circuit.json" ;
if _n_=1 then put '[';
if not eof then delim=',';
put '{"Value":' Value ' "Text":' Text'}' delim ;
if eof then put ']';
run;

NOTE: 351 records were written to the file "/../../../././JSON/test_Circuit.json".

 

I am referring @ 

https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/p0qapul7pyz9hmn0zfoefj0c278a.......

 

Thanks again....

 

 

 

 

GPatel
Pyrite | Level 9
Dear Gwootton :
I used your suggestive action.....Here is log....
filename jobout filesrvc
parenturi='/files/files/e2a8832f-03ce-46c8-ba5d-df61136c922c';
data _null_;
set Unq_Circuit end=eof;
file jobout('test_Circuit.json') ;
if _n_=1 then put '[';
if not eof then delim=',';
put '{"Value":' Value ' "Text":' Text'}' delim ;
if eof then put ']';
run;

79 filename jobout filesrvc
80 parenturi='/files/files/e2a8832f-03ce-46c8-ba5d-df61136c922c';
81 data _null_;
82 set Unq_Circuit end=eof;
83 file jobout('test_Circuit.json') ;
84 if _n_=1 then put '[';
85 if not eof then delim=',';
86 put '{"Value":' Value ' "Text":' Text'}' delim ;
87 if eof then put ']';
88 run;
NOTE: The file library JOBOUT is:
Directory=/files/files?parentUri=/files/files/e2a8832f-03ce-46c8-ba5d-df61136c922c,
Description=Directory for ParentUri collection
NOTE: The file JOBOUT('test_Circuit.json') is:
Filename=test_Circuit.json,
URI path=/files/files/9f0061da-9011-47b0-821d-1358b093cd11,
File Identifier=9f0061da-9011-47b0-821d-1358b093cd11,
Content Type=application/json,
Parent URI=/files/files/e2a8832f-03ce-46c8-ba5d-df61136c922c,
Encoding=UTF-8,Searchable=false,RECFM=V,
LRECL=32767,File Size (bytes)=10474,
Last Modified=29Jul2022:19:52:56,
Create Time=29Jul2022:19:51:38
NOTE: A total of 351 records were written to the file library JOBOUT.
The minimum record length was 1.
The maximum record length was 29.
NOTE: 351 records were written to the file JOBOUT('test_Circuit.json').
The minimum record length was 1.
The maximum record length was 29.
NOTE: There were 349 observations read from the data set WORK.UNQ_CIRCUIT.
NOTE: DATA statement used (Total process time):
real time 0.48 seconds


But I could not locate this file!



GPatel
Pyrite | Level 9
Thanks to all, and specially to Dear Gwootton :

Upon updating SAS code to this....It worked like  a charm.

 
filename jobout filesrvc folderPath='/Public/Json';

data _null_;
set Unq_Circuit end=eof;
file jobout('test_Circuit.json') ;
if _n_=1 then put '[';
if not eof then delim=',';
put '{"Value":' Value ' "Text":' Text'}' delim ;
if eof then put ']';
run;
79 filename jobout filesrvc folderPath='/Public/Json';
80
81 data _null_;
82 set Unq_Circuit end=eof;
83 file jobout('test_Circuit.json') ;
84 if _n_=1 then put '[';
85 if not eof then delim=',';
86 put '{"Value":' Value ' "Text":' Text'}' delim ;
87 if eof then put ']';
88 run;
NOTE: The file library JOBOUT is:
Directory=/Public/Json,
Folder Identifier=4880eafd-d5e5-4ae6-ad0e-7e242d0b44d9,
Last Modified=10Jan2022:19:18:17
NOTE: The file JOBOUT('test_Circuit.json') is:
Filename=Test_Circuit.json,
URI path=/files/files/e2a8832f-03ce-46c8-ba5d-df61136c922c,
File Identifier=e2a8832f-03ce-46c8-ba5d-df61136c922c,
Document Type=file,Content Type=text/plain,
Content Disposition=inline;filename*=utf-8''Test_Circuit.json,
Encoding=UTF-8,Searchable=true,RECFM=V,
LRECL=32767,File Size (bytes)=0,
Last Modified=29Jul2022:19:50:59,
Create Time=29Jul2022:19:50:58
NOTE: A total of 351 records were written to the file library JOBOUT.
The minimum record length was 1.
The maximum record length was 29.
NOTE: 351 records were written to the file JOBOUT('test_Circuit.json').
The minimum record length was 1.
The maximum record length was 29.
NOTE: There were 349 observations read from the data set WORK.UNQ_CIRCUIT.
NOTE: DATA statement used (Total process time):
real time 0.66 seconds
GPatel
Pyrite | Level 9
Thanks Dear Gwootton. I appreciate your insight, attention, and support. I learned some thing new and useful in VIYA world.

_ GPatel

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Discussion stats
  • 10 replies
  • 1519 views
  • 2 likes
  • 4 in conversation