data here.knownSecType;
input secType $;
datalines;
cmn
option
;
run;
The 2 datalines each have 2 tab characters before the string. When I run it interactively, the resulting dataset has no tabs in the secType field (e.g. "cmn"). When I run it in batch mode, I get tabs (e.g." cmn"). Can anyone explain this?
(It's an issue because I'm helping a colleague develop some code and we want to work from one codebase. He works interactively; I work in batch. Subsequent joins with this table work for him and not for me.)lk
Add it :
data here.knownSecType;
infile cards expandtabs;
input secType $;
datalines;
cmn
option
;
run;
Xia Keshan
I'm surprised no one has responded. Too simple? This kind of basic stuff sometimes vexes me.
It does not convert the tabs on submission when using the old style PGM window in SAS 9.2 on a Unix machine.
17 data _null_;
18 input secType $;
19 list;
20 datalines;
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
21 CHAR ..cmn
ZONE 00666222222222222222222222222222222222222222222222222222222222222222222222222222
NUMR 993DE000000000000000000000000000000000000000000000000000000000000000000000000000
22 CHAR ..option
ZONE 00677666222222222222222222222222222222222222222222222222222222222222222222222222
NUMR 99F049FE000000000000000000000000000000000000000000000000000000000000000000000000
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
23 ;
24 run;
Are you using the "enhanced" editor?
The "enhanced editor" will also honor the tab stops you have set in the options when converting these tabs to spaces. So with tab stops set at 4 characters you get this:
2730 data _null_;
2731 input secType $;
2732 list;
2733 datalines;
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8---
2734 cmn
2735 option
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2736 ;
2737 run
My colleague is the interactive one. I'm 47 years old, so I use batch mode. All that pointing and clicking bugs me.
Jdmarino, the last reply about age is too tempting, you are still a youngster. I like the interactive approaches, the encoding challenges etc.
As you are using Notepad++ it also there with a nice indication for encoding. If you ever hit the BOM indicator you will see what I mean.
Strange the fixed 8 position translation with SAS. If you do this in notepad++ it are 4 positions, however you can change it to a personal value.
Add it :
data here.knownSecType;
infile cards expandtabs;
input secType $;
datalines;
cmn
option
;
run;
Xia Keshan
Worked like a charm. I have to say, after I read the help on the infile statement (where the expandtabs option help is), there is no way I would have expected it to solve this problem, so your reply was valuable. Thanks.
@jdmarino, As now you have been surprised by smart editor behavior. Just using old style Single-byte encoding.
Try this type of effects using UTF8 session encoding and more of those. You will be really surprised.
My colleague is the one who runs things interactively. I use notepad++ to edit a file and run it in batch mode: no problems!
Whatever editor you use I find that is causes problems to include tabs inside the program file.
In whatever editor you are using take advantage of the settings they have to convert the tabs to spaces. Most editors will let you do this. You can still use the tab key when typing to make things align but your saved files will not have those nasty tabs interspersed in random places in the text.
I agree. And I do that (have my editor convert tabs to spaces). And I wrote to my colleague to warn him that "tabs are EVIL".
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.