BookmarkSubscribeRSS Feed
Sean_OConnor
Fluorite | Level 6

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3883 views
  • 1 like
  • 3 in conversation