Skip to content

Instantly share code, notes, and snippets.

@ccw
Created March 28, 2012 14:01
Show Gist options
  • Select an option

  • Save ccw/2226430 to your computer and use it in GitHub Desktop.

Select an option

Save ccw/2226430 to your computer and use it in GitHub Desktop.
[SAS] Output Dataset as JSON
LIBNAME EDA ORACLE PATH=XE SCHEMA=EDA USER=eda PASSWORD=eda;
DATA WAT;
SET EDA.WAT;
KEEP PRODUCT_NAME SPEC_FILE LOT_ID WAFER_ID SITE_ID ATT1 ATT2 ATT3;
WHERE LOT_ID like 'P0M78.1';
RUN;
DATA _NULL_;
file print PS=32767;
set WAT end=lastrec;
if _N_ eq 1 then do;
put '[';
end;
put '{"productName":"' PRODUCT_NAME '",';
put '"lotId":"' LOT_ID '",';
put '"waferId":' WAFER_ID ',';
put '"siteId":"' SITE_ID '",';
put '"specFile":"' SPEC_FILE '",';
put '"attrs": [';
put '{"attr1":' ATT1 '},';
put '{"attr2":' ATT2 '},';
put '{"attr3":' ATT3 '}]}';
if lastrec eq 1 then do;
put ']';
end;
else do;
put ',';
end;
RUN;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment