BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jdmarino
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Add it :

data here.knownSecType;

  infile cards expandtabs;

  input secType $;

  datalines;

  cmn

  option

  ;

run;


Xia Keshan

View solution in original post

10 REPLIES 10
jdmarino
Fluorite | Level 6

I'm surprised no one has responded.  Too simple?  This kind of basic stuff sometimes vexes me.

Tom
Super User Tom
Super User

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

jdmarino
Fluorite | Level 6

My colleague is the interactive one.  I'm 47 years old, so I use batch mode.  All that pointing and clicking bugs me.Smiley Wink

jakarman
Barite | Level 11

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.   

---->-- ja karman --<-----
Ksharp
Super User

Add it :

data here.knownSecType;

  infile cards expandtabs;

  input secType $;

  datalines;

  cmn

  option

  ;

run;


Xia Keshan

jdmarino
Fluorite | Level 6

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.

jakarman
Barite | Level 11

@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.

---->-- ja karman --<-----
jdmarino
Fluorite | Level 6

My colleague is the one who runs things interactively.  I use notepad++ to edit a file and run it in batch mode: no problems!

Tom
Super User Tom
Super User

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.

jdmarino
Fluorite | Level 6

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".

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1870 views
  • 2 likes
  • 4 in conversation