Help using Base SAS procedures

Truncated record??

Accepted Solution Solved
Reply
Super Contributor
Posts: 259
Accepted Solution

Truncated record??

Hi

Quick question

I have a small sas program that runs 'proc sql; create table' procedure which runs perfectly when I open the program and run it but when I try to call it using %include call(Reconciliation), I get an error message saying "Truncated Record" and "Syntax Error"

Since it works fine when I open up the program and run it rather than calling it from another program I assume it is something to do with my %Include... code.

Any ideas?

Many thanks


Error.png
Attachment

Accepted Solutions
Solution
‎08-18-2014 07:10 AM
Respected Advisor
Posts: 4,173

Re: Truncated record??

I observe the same in my environment (SAS9.4M0 under Win7). Don't understand the "why" yet.

Can you try and run your code similar to below and tell us if this works for you (it does for me):

filename call 'C:\test';

options s=0 s2=0;

%include call(test.sas) /source2 ;

View solution in original post


All Replies
Super User
Super User
Posts: 7,950

Re: Truncated record??

Can you post the code, can check it then?  Also, what are you running on , SAS9.3 or EG etc.

Super Contributor
Posts: 259

Re: Truncated record??

SAS 9.2 for Windows

I have attached the program I call called "Reconciliation". I call this from another program using %include call(Reconciliation) where call defined as Filename Call 'location...';.

Super User
Super User
Posts: 7,950

Re: Truncated record??

Ah yes, you have this: "%" in the text.  The double quotes around a % indicates that SAS should find the macro variable from the symbol table and replace this, though its not a macro call.  Replace the double quotes with single quotes.  You also have a special character in: "Difference -I90 VS SAS Program ", and "EP Premium Breakdown " - note the space after it.
Updated:

proc sql;

  create table Rec_Summary_MFR   

  (

    REC_SUMMARY_MFR char(200),

    EY2012 char(200)

  );

  insert into Rec_Summary_MFR

  set     REC_SUMMARY_MFR="Earned Premium - SAS Program",    

  EY2012= (select PUT(round(sum(EP2012),1),BEST.) from EP_CALC where POLTYR = 'MFR')  

  set     REC_SUMMARY_MFR="Earned Premium - I90",    

  EY2012= (select PUT(round(sum(enprmw),1),BEST.) from TPERND WHERE POLTYR = 'MFR' AND ernyrw = 2012)

  set     REC_SUMMARY_MFR="Difference -I90 VS SAS Program",    

  EY2012= CATT(input(put((((select round(sum(enprmw),1) from TPERND WHERE POLTYR = 'MFR' AND ernyrw = 2012)/(select round(sum(enprmw),1) from TPERND WHERE POLTYR = 'MFR' AND ernyrw = 2012))-1)*100,5.2),best.),'%')

  set     REC_SUMMARY_MFR="EP Premium Breakdown",    

  EY2012= ""

  set     REC_SUMMARY_MFR="Difference 1 - Batch month before expiry date but after 1st month of exposure period",    

  EY2012= CATT((select PUT(round(sum(DIFF12012),1),BEST.) from EP_CALC WHERE POLTYR = 'MFR')," (",INPUT(PUT(((select round(sum(DIFF12012),1)from EP_CALC WHERE POLTYR = 'MFR')/(select round(sum(EP2012),1)from EP_CALC WHERE POLTYR = 'MFR'))*100,5.1),BEST.),'%)')

  set     REC_SUMMARY_MFR="Difference 2 - Batch month after expiry date and premium full earned in batch month",    

  EY2012= CATT((select PUT(round(sum(DIFF22012),1),BEST.) from EP_CALC WHERE POLTYR = 'MFR')," (",INPUT(PUT(((select round(sum(DIFF22012),1)from EP_CALC WHERE POLTYR = 'MFR')/(select round(sum(EP2012),1)from EP_CALC WHERE POLTYR = 'MFR'))*100,5.1),BEST.),'%)')

  set     REC_SUMMARY_MFR="Difference 3 - Batch month before expiry date and premium full earned in batch month",    

  EY2012= CATT((select PUT(round(sum(DIFF32012),1),BEST.) from EP_CALC WHERE POLTYR = 'MFR')," (",INPUT(PUT(((select round(sum(DIFF32012),1)from EP_CALC WHERE POLTYR = 'MFR')/(select round(sum(EP2012),1)from EP_CALC WHERE POLTYR = 'MFR'))*100,5.1),BEST.),'%)')

  ;

quit;

Super Contributor
Posts: 259

Re: Truncated record??

Hi RW9

I made that change but I'm still getting an error message. I have attached a screenshot of the message. I changed the followin in my program - replaced "%" with '%' and put a space after the special character

Super User
Super User
Posts: 7,950

Re: Truncated record??

Yes, you still have special characters in the code.  Use the text I posted above, copy that into your SAS window and submit it (mine fails as the dataset are not present, but it should work ok for you).  Then copy and paste that over your include file.

Super Contributor
Posts: 259

Re: Truncated record??

I copied your code exactly and I'm still getting the same error message. I've attached a screenshot of the error.

Super User
Super User
Posts: 7,950

Re: Truncated record??

Does it run correctly just in a Enhanced Editor window?  (i.e. don't use as include)

Super Contributor
Posts: 259

Re: Truncated record??

Yes

Super User
Super User
Posts: 7,950

Re: Truncated record??

Plus 1 to Patrick's suggestion.  I am still not sure how it is 'running correctly' in you SAS Editor.  I am just running through aligning code and layout and am noticing odd things which should come up as issues:

Row for EY2012=, the second from has no space between it and the preceding (.  This happens in a couple of instances.  I would suggest some code re-formatting to make it a bit more readable so these kind of things jump out.  For instance each sub-query on a new row, indented within functions etc.  Will see if I can do an example after lunch.

Super Contributor
Posts: 259

Re: Truncated record??

It does work in editor. I know the formatting is a bit messy but it does definitely work. It's only when I %include call(..) that it falls down

Super User
Super User
Posts: 7,950

Re: Truncated record??

Just to add onto my previous post, try shrinking each line a bit, having sections of code on different lines, e.g. select and from on different rows, all indented the same.  I always try to keep my code no longer the 100 characters, avoids all that scrolling across, also you can have unlimited lines but width is restricted which maybe what you are hitting here.  (note the spacing seems different on here so paste into code window to see properly). 

proc sql;
  create table Rec_Summary_MFR   
  (
    REC_SUMMARY_MFR char(200),
    EY2012 char(200)
  );

  insert into Rec_Summary_MFR
  set     REC_SUMMARY_MFR="Earned Premium - SAS Program",    
          EY2012= (select put(round(sum(EP2012),1),BEST.)
                   from   EP_CALC
                   where  POLTYR="MFR")  
  set     REC_SUMMARY_MFR="Earned Premium - I90",    
          EY2012=(select  PUT(round(sum(enprmw),1),BEST.)
                  from    TPERND
                  where   POLTYR="MFR"
                      and ERNYRW=2012)
  set     REC_SUMMARY_MFR="Difference -I90 VS SAS Program",    
          EY2012=(select  strip(put((round(sum(BASE.ENPRMW),1) / round(sum(LAST.ENPRMW),1),5.2))||"%"
                  from    (select * from TPERND where POLTYR="MFR" and ERNYRW=2012) BASE
                  left join (select * from TPERND where POLTYR="MFR" and ERNYRW=2011) LAST
                  on      BASE.ERNTRW=LAST.ERNTRW)
....;
quit;

Respected Advisor
Posts: 4,173

Re: Truncated record??

Code working fine as such but throwing a "truncated" error when using in an %include statement. Hmm.... Your code lines are very long (almost 280 characters). What comes to mind is option "S2" SAS(R) 9.3 System Options: Reference, Second Edition

Use below before your %include statement and let us know if this helps.

options s2=max;

Super Contributor
Posts: 259

Re: Truncated record??

When i use the code

options s2=max;
%include call(reconcilaition);

nothing appears to run

Solution
‎08-18-2014 07:10 AM
Respected Advisor
Posts: 4,173

Re: Truncated record??

I observe the same in my environment (SAS9.4M0 under Win7). Don't understand the "why" yet.

Can you try and run your code similar to below and tell us if this works for you (it does for me):

filename call 'C:\test';

options s=0 s2=0;

%include call(test.sas) /source2 ;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 19 replies
  • 1750 views
  • 6 likes
  • 4 in conversation