내가 SAS와 JSON 형식의 데이터를 내보내는거야 포맷 값을 연결하는 방법 :내가 만든이 매크로 사용하여 SAS
%macro json4datatables(ds,path,file,charvars,numvars)
/store source
DES="json4datatables(ds,path,file,charvars,numvars)";
/* creates a json with no headers
* a bit like a csv without the first line
* it takes thus less space
* but you have to know which column is what
*/
data _null_;
length line $300;
set &ds nobs=nobs end=end;
file "&path.&file." encoding='utf-8' bom/**/ ;
line = '[';
%if &charvars ne %then %do;
%do i=1 %to %sysfunc(countw(&charvars));
%let charvar = %scan(&charvars, &i);
%if &i ne 1 %then %do;
line = cats(line,',');
%end;
line = cats(line,'"',&charvar,'"');
%end;
%end;
%if &numvars ne %then %do;
%do i=1 %to %sysfunc(countw(&numvars));
%let numvar = %scan(&numvars, &i);
%if &i ne 1 OR &charvars ne %then %do;
line = cats(line,',');
%end;
line = cats(line,'',&numvar,'');
%end;
%end;
line = cats(line,']');
if _n_=1 then put '{"data": [';
if not end then put line +(-1) ',';
else do;
put line;
put ']}';
end;
run;
%mend json4datatables;
을하지만 내 문제는 원료 값이 수출되고 있다는 점이다.
서식이 지정된 값을 내보내 려합니다.
어떻게하면됩니까?
나는 값 대신 형식화 된 값을 연결할 수있는 함수가있을 것이라고 생각하고 cats()를 그 값으로 바꿀 수 있습니다.
감사합니다.
감사! 그리고 나는 고양이에게 익숙해 져서, 그것은 나를 위해 읽을 수있는 것을 더 쉽게 만들어 주지만, 나는 시도 할 것입니다. –
catx 대체가 작동하지 않으면 첫 번째 값'[, "BORPER", "fatal_1", "0.78"], ' –
'앞에 쉼표가 추가됩니다. LINE 변수가 비어 있지 않기 때문입니다. 쉼표로 구분 된 값을 먼저 작성한 다음 나중에 대괄호를 추가 할 수 있습니다. – Tom