SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Pandu2
Obsidian | Level 7

My Apologies, it didn't work. It has only fieldname and fieldvalue.

Reeza
Super User

Try it again, the last part of the code got deleted for some reason. I added it back in.

Reeza
Super User

@Pandu2 wrote:

Actually when a new batchNo comes that's the sign of previous BatchNo group ends. That's how I figured out after doing some analysis how the group ends, otherwise our business and I doesn't know how it ends cuz the complexity of data and not following any specific pattern.


That's why the parenthesis are important. They delimit the batches and lines. 

Pandu2
Obsidian | Level 7
Here's the original format of my json data:

{ """BatchNo"":""001"""" "Keys": [ { """Goodsname"":""Nikeshoes"""" """Quantity"":""3"""" """Infotype"":""Sneakers"""" } { """Goodsname"":""pants"""" """Quantity"":""5"""" """Infotype"":""Trackpants"""" """Newly"":"""""" """Infotype"":""RAQ"""" """TypeId"":""109"""" """Cause"":""Broken"""" """Quantity"":""0"""" } }{ """BatchNo"":""009"""" "Keys":[ { """Goodsname"":""Nikeshoes"""" """Quantity"":""3"""" """Infotype"":""Sneakers"""" }{ """Goodsname"":""pants"""" """Quantity"":""5"""" """Infotype"":""Trackpants"""" } ] } { """BatchNo"":""011"""" "Keys":[ { """Goodsname"":""Jackets"""" """Quantity"":""3"""" """Infotype"":""topwears"""" } """Newly"":"""""" """Infotype"":""RAQ"""" """TypeId"":""100"""" """Cause"":""Broken"""" """Quantity"":""0"""" ] }
Sajid01
Meteorite | Level 14

Thanks @Pandu2 for posting the original json. It is not a well formed json and there is no uniformity between the different records.

For example, for BatchNo 001  there is no closing square bracket '.]' . 
So whatever approach you are going to use, data cleaning preparation would consume time. If it is possible, make sure that data comes in a proper format. 

Pandu2
Obsidian | Level 7
I just posted how the way it looks like and I kinda agree with you that it doesn't follow a specific pattern.
andreas_lds
Jade | Level 19

@Pandu2 wrote:

Please I request you to help me on this.


Please post the complete log. It is impossible to debug something without knowing what happened actually.

Pandu2
Obsidian | Level 7

Log:

 

NOTE: There were 3417992 observations read from the data set work.have.

NOTE: The data set work.want has 1 observations and  10 variables.

NOTE: Compressing data set work.want increased size by 100.00 percent.

Compressing is 2 pages; un- compressed would  require 1 pages.

NOTE: DATA statement used(Total process time). 

Only these set of lines I've it on my sas log.

andreas_lds
Jade | Level 19

Well, i wouldn't invest more time in my solution, but try to import the json file directly with libname statement. Have look at https://support.sas.com/resources/papers/proceedings17/0856-2017.pdf

 

The log has nothing of value, which means that something in the file is not as expected. Adding some put-statements could help, but i would postpone this, and give the more recent tools to handle json a chance.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 23 replies
  • 2098 views
  • 8 likes
  • 5 in conversation