BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

Hello,

 

The %tslit function is working properly using SAS EG either when we use the development server or the production server.  But when comes the time to use that piece of code below, I am getting this error:

 

MPRINT(TXNCNCTIMPTFRMORA): filename jsonf "/dwh_actuariat/sasdata/current/OneCx_Qualitrics/BOnline_S2023032912000000.json";
MPRINT(TXNCNCTIMPTFRMORA): data _null_;
MPRINT(TXNCNCTIMPTFRMORA): infile dest1 end=eof;
22: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, arrayname, #, (, +, /, //, ;, @, @@,
OVERPRINT, _ALL_, _BLANKPAGE_, _ODS_, _PAGE_.
200: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 200-322: The symbol is not recognized and will be ignored.
MPRINT(TXNCNCTIMPTFRMORA): file jsonf;
WARNING: Apparent invocation of macro TSLIT not resolved.
MPRINT(TXNCNCTIMPTFRMORA): if _n_=1 then put %tslit({"contacts":);
MPRINT(TXNCNCTIMPTFRMORA): input;
MPRINT(TXNCNCTIMPTFRMORA): put _infile_;
MPRINT(TXNCNCTIMPTFRMORA): if eof then put '}';
MPRINT(TXNCNCTIMPTFRMORA): run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):

 

The code:

 

/* Making a copy of the json file on the server */

		filename &dest. %sysfunc(quote(%sysfunc(pathname(&dest.))/&JsonFName&orderdate.&ordertime..json));

		data _null_;
  			infile dest1 end=eof;
  			file &dest.;
  			if _n_=1 then put %tslit({"transactionMeta":{"batchId":"&batchid."%str(,) "fields":[&vars.]}%str(,)"contacts":[);
  			input;
  			put _infile_;
  			if eof then put ']}';
		run;

Any suggestion or work aroung solution?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Probably path with %Tslit() for sasautos is not added to the session setup. 

Try not using %tslit(), for example: 

data _null_;
  infile dest1 end=eof;
  file &dest.;
  if _n_=1 then
    do;
      length header $ 1024; 
      header = cats( 
      '{"transactionMeta":{"batchId":"',symget("batchid"),'"%str, "fields":[',symget("vars"),']},"contacts":['
      );
      put header;
    end;
  input;
  put _infile_;
  if eof then put ']}';
run;

 

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

3 REPLIES 3
yabwon
Onyx | Level 15

Probably path with %Tslit() for sasautos is not added to the session setup. 

Try not using %tslit(), for example: 

data _null_;
  infile dest1 end=eof;
  file &dest.;
  if _n_=1 then
    do;
      length header $ 1024; 
      header = cats( 
      '{"transactionMeta":{"batchId":"',symget("batchid"),'"%str, "fields":[',symget("vars"),']},"contacts":['
      );
      put header;
    end;
  input;
  put _infile_;
  if eof then put ']}';
run;

 

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Quentin
Super User

Are you sure that whole error is coming just from the unresolved macro reference?

 

I agree with Bart, it's probably a problem with the autocall library set up.

 

But I would check by running a simple test:

%put %tslit(foo) ;

Just to make sure the problem isn't somewhere else in the macro TXNCNCTIMPTFRMORA.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Tom
Super User Tom
Super User

No need for the macro %TSLIT() you can just call the actual QUOTE() and tell it to use single quotes.

%put %tslit(xyz);
%put %sysfunc(quote(xyz,%str(%')));

But since the goal is just to write to a text file why bother with any macro logic? The PUT statement should be able to handle what you want to do.

/* Making a copy of the json file on the server */

filename &dest. %sysfunc(quote(%sysfunc(pathname(&dest.))/&JsonFName&orderdate.&ordertime..json));

data _null_;
  infile dest1 end=eof;
  file &dest.;
  if _n_=1 then put '{"transactionMeta":{"batchId":"' "&batchid." '", "fields":[' "&vars." ']},"contacts":[';
  input;
  put _infile_;
  if eof then put ']}';
run;

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 567 views
  • 2 likes
  • 4 in conversation