BookmarkSubscribeRSS Feed
yichentian226
Obsidian | Level 7

Hi everyone,

 

I have the JSON file and I need to convert this JSON file, that is in text format, into a SAS dataset.  Attached is the example JSON text file. Any help or suggestion is appreciated. 

 

Schema in the table:

_id

barcode

brandCode

category

categoryCode

cpg

topBrand

name

 

Sample: 

 

{"_id":{"$oid":"601ac115be37ce2ead437551"},"barcode":"511111019862","category":"Baking","categoryCode":"BAKING","cpg":{"$id":{"$oid":"601ac114be37ce2ead437550"},"$ref":"Cogs"},"name":"test brand @1612366101024","topBrand":false}
{"_id:{"$oid":"601c5460be37ce2ead43755f"},"barcode":"511111519928","brandCode":"STARBUCKS","category":"Beverages","categoryCode":"BEVERAGES","cpg":{"$id":{"$oid":"5332f5fbe4b03c9a25efd0ba"},"$ref":"Cogs"},"name":"Starbucks","topBrand":false}


2 REPLIES 2
Reeza
Super User
Have you tried saving the file to a text file/JSON file and then using libname JSON?
https://blogs.sas.com/content/sasdummy/2016/12/02/json-libname-engine-sas/
yichentian226
Obsidian | Level 7

Thanks for the reply. I read that article earlier and got error while trying to run it myself. I guess I wasn't understanding the "proc http
url= "&fullurl.", in this case will I need to save the file in a web path? My file is saved as txt on the desktop. 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1438 views
  • 1 like
  • 2 in conversation