BookmarkSubscribeRSS Feed
rboire
Calcite | Level 5

here is the error when I read this data. there are no observations. Why ?

 

 filename data '\\kashmir\BFD\sample_json1_may26.txt';


6300  data datatest;
6301   infile data lrecl = 32000 truncover scanover;
6302   input @'"text": "' text $255. @'"from_user": "' from_user $255. @'"created_at": "' created_at
6302! $255. ;
6303  /*text = substr(text,1,index(text,'",')-2); from_user = substr( from_user,1,index(
6303! from_user,'",')-2);
6304  created_at = substr(created_at,1,index(created_at,'",')-2); run;
6305    */

NOTE: The infile DATA is:
      Filename=\\kashmir\BFD\sample_json1_may26.txt,
      RECFM=V,LRECL=32000,File Size (bytes)=1989,
      Last Modified=26May2017:12:28:24,
      Create Time=26May2017:12:09:11

NOTE: 3 records were read from the infile DATA.
      The minimum record length was 1.
      The maximum record length was 1134.
NOTE: SAS went to a new line when INPUT @'CHARACTER_STRING' scanned past the end of a line.
NOTE: The data set WORK.DATATEST has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


6306  proc print data=dataset;run;
ERROR: File WORK.DATASET.DATA does not exist.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

 

2 REPLIES 2
ballardw
Super User

Without actually seeing the data file here is something to check:

 

When using the Input @'text value' then the value you supply in the code must be exactly as it appears in the source file.

If the file has "Text value" then it does not match 'text value'

 

Also the "Minimum record length was 1" may indicate you don't even want to attempt the read the first line. Perhaps add "firstobs=2" to accomplish that.

ChrisBrooks
Ammonite | Level 13

If you're using SAS 9.4 you might find the JSON library engine much easier to use than trying to parse it yourself. The details are here

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 1140 views
  • 0 likes
  • 3 in conversation