BookmarkSubscribeRSS Feed
Sean_OConnor
Obsidian | Level 7

Folks,

 

I have a Json file which I need to create a SAS dataset with.

 

To begin I've used R to separate the Json file into four different datasets and I have exported them out into a .sav file.

 

I am then reading the .sav file into SAS using the proc import command.

 

However, after the proc import command is run all the variables are being read in as numeric. For example a variable called.

 

additionalProp1 has a value called 'string'. In the SAS dataset this is being read as numeric.

 

Does anyone know why SAS is reading all variables in as numeric? Is it something to do with the structure of the .sav file?

 

Any information would be great.

 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is a .sav file?  Something for SPSS?  Why not just export to CSV and read that into SAS?

If you JSON file isn't too complicated, you should be able to read it in via datastep - never use proc import for anything other than playing around as it is a guessing procedure -, and you could probably output all four datasets from one datastep.  The JSON file is just a plain text file that can be read line by line, so some conditional statements to control which data goes where should be enough.

Personally I would avoid the whole R step and just read the JSON file into SAS directly.

BillM_SAS
SAS Employee

If you have SAS 9.4 maintenance 4 (or better), you have access to the JSON LIBNAME statement for reading JSON data into SAS data sets.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4733 views
  • 1 like
  • 3 in conversation