My SAS code "a.sas" is in Desktop.
data have;
input code :$5. country $13.;
cards;
USA United States
;
proc print;
run;
This code standalone prints the following.
Obs code country 1 USA United States
Another SAS code "b.sas" %INCLUDEs the "a.sas" code as follows.
%include "!userprofile\desktop\a.sas";
And the results are inconsistent.
Obs code country 1 USA U States
It seems this difference is related to the tab in between "USA" and "United States" but unclear. I read Rule for Using %INCLUDE in %INCLUDE Statement but I couldn't find the relevant—spacing versus tabbing—issues. What's the reason for this difference?
SAS DIsplay Manager tries to help you out by fixing your mistake of embedding tabs in your data when it submits the code to run.
You can use the EXPANDTABS option on an infile statement to fix it yourself.
data have;
infile cards expandtabs;
input code :$5. country $13.;
cards;
USA United States
;
Or better still just stop putting tab characters into your program files.
SAS DIsplay Manager tries to help you out by fixing your mistake of embedding tabs in your data when it submits the code to run.
You can use the EXPANDTABS option on an infile statement to fix it yourself.
data have;
infile cards expandtabs;
input code :$5. country $13.;
cards;
USA United States
;
Or better still just stop putting tab characters into your program files.
Thanks for this help. Just to make sure, may I ask slightly more? The standalone code runs as I intend even without EXPANDTABS, while %INCLUDE requires EXPANDTABS to do so—which I didn't anticipate beforehand.
(1) Why do they—standalone versus %INCLUDE—behave differently here? Shouldn't their results be identical?
(2) If not, is there any similar %INCLUDE-specific difference? Because I didn't expect their difference so far, I didn't seriously consider these issues (such as tabbing or spacing) as well when coding. Probably I would have to review again to avoid unwanted errors.
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.
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.
Ready to level-up your skills? Choose your own adventure.