BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

Just read that into a different variable, call it EXTRA.  No need to change your delimiters.

You can even test if it looks like a TAG value (all digits) and and reset the column pointer to column 1 when it does so you don't end up reading the first TAG value into EXTRA and getting everything out of sync.

data x;
  infile "C:\Users\jwalker\Desktop\New folder (2)\FedLine32948_PCBB_FXWIRE_FEDLINE_202107201050.txt"
    dlm='{}' truncover
  ;
  length row col 8 extra tag $32 text $1000;
  row+1;
  input extra @;
  if not notdigit(extra) then input @1 @ ;
  do col=1 by 1 until(tag=' ');
    input tag text @;
    if tag ne ' ' then output;
  end;
run;

Looking at the documentation you might even want to make TAG a numeric variable since all of the values are 4 digit numbers.  Then you could add the extra input the first tag is missing.

data x;
  infile "C:\Users\jwalker\Desktop\New folder (2)\FedLine32948_PCBB_FXWIRE_FEDLINE_202107201050.txt"
    dlm='{}' truncover
  ;
  length row col tag 8 extra $32 text $1000;
  row+1;
  input tag ?? @1 @;
  if missing(tag) then input extra @ ;
  do col=1 by 1 until(missing(tag));
    input tag text @;
    if not missing(tag) then output;
  end;
run;
jimbobob
Quartz | Level 8
Man you're a genius, I've been trying to figure this out for 4 hours. Thank you so much.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 16 replies
  • 9714 views
  • 0 likes
  • 4 in conversation