%DO is not as flexible as DO. Make a list and loop over an index into the list. Note: the %UNQUOTE() is because sometimes the parser can get confused by this type of syntax and treat the XYZ and %SCAN() as separate tokens. %let suffix=1 2 3 8 10; data x ; set %do i=1 %to %sysfunc(countw(&suffix,%str( ))); %unquote(xyz%scan(&suffix,&i,%str( ))) %end; ; run;
... View more
In the other example there is truncation because $10 defines the length of the otherwise undeclared character variable. The input statement with :$10. reads until the delimiter is found with is demonstrated by the COLUMN position. Truncation occurs when the character string is stored or written to the PDV (I suppose is a good enough way to describe it).
... View more
When you use the colon SAS uses LIST input which scans the record until the delimeter is found. The blank in this case. So even though you specify $10. the input still scans until the delimiter is found in column 17 and the pointer is position at col=18 for the next read. You have age 2. (formatted input) now but you are passed the spot where you need to be. Also $10. defines the length of date which truncates the 2 extra characters in the blank delimited field. 17 data _null_; 18 infile cards column=col; 19 input id date $:10. @; 20 put date= col=; 21 input age 2.; 22 put age= col=; 23 list; 24 cards; date=12/11/1983 col=18 age=. col=20 RULE: ----+----1----+----2----+---- 25 102 12/11/198312 date=12/11/1989 col=18 age=. col=20 26 103 12/11/198914
... View more