I am using the row+; in the following code but it is not generating the row variable as the JSON engine would make the ordinal variable. filename dirtree url
'https://raw.githubusercontent.com/sasutils/macros/master/dirtree.sas';
%include dirtree /source2;
%dirtree(C:\Users\mq10004085\Macquarie University\MRFF Aged care Data - Documents\json_test /* Pipe delimited directory list (default=.) */
, out=filelist /* Output dataset name */
, maxdepth=1 /* Maximum tree depth */);
%macro read_json(myfile=, group = );
filename mydata &myfile.;
libname myjson JSON fileref=mydata nrm;;
proc datasets lib=myjson;
quit;
*how to parse the file has not been specified - looks like you need to specify the lengths;
data file2save;
length source $200. p1 $256. Value $256.;
set myjson.alldata;
source=&myfile.;
row+1; run;
proc append base=master_&group data=file2save force; run;
proc sql;
drop table file2save;
quit;
filename mydata;
libname myjson;
%mend read_json;
proc sql;
drop table master;
quit;
data run_list;
set filelist;
where type='F';
*add other logic to add group variable, this is just an example;
group=substr(filename, 1, find(filename,'_'));
*test this is created correctly;
str=catt('%read_json(myfile="C:\Users\mq10004085\Macquarie University\MRFF Aged care Data - Documents\json_test\', filename, '", group=', group, ');');
*once tests are complete uncomment the execution to test it;
call execute(str);
run; This is how it looks like.
... View more