BookmarkSubscribeRSS Feed
buddha_d
Pyrite | Level 9

I am reading a tab delimited file with infile statement and input. I need to do tranformation and concatenate couple of variables and export it to tab delimited file. But the output has more spaces than the original. Has anyone experienced this?

 

Thanks,

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Can you provide some sample data?

buddha_d
Pyrite | Level 9

I am adding _sequence number to station field (based on date ) like 1/26/2009 date will have B-123_1 & 3/23/2009 will have B-123_2. 

once I have it like this transformation of data, I need to export data. I have very large data but submitting small set. 

Thanks

Kurt_Bremser
Super User

Your data is defective after record 10 (missing tab character after station_description), so I limited my code to the first 10 lines:

data have;
infile '$HOME/sascommunity/EColi_tab.txt' dlm='09'x firstobs=2 obs=10 truncover;
input
  Record
  STATION :$6.
  STATION_DESCRIPTION :$20.
  COLLECTION_DATE :mmddyy10.
  FecalColi
  FecalRemark :$5.
  Enterococci
  EnteroRemark :$5.
  Ecoli
  EcoliRemark :$5.
  Nav_Status :$6.
;
format COLLECTION_DATE mmddyy10.;
run;

proc sort data=have;
by station collection_date;
run;

data want;
set have;
by station;
if first.station
then counter = 1;
else counter + 1;
station_seq = trim(station) !! '_' !! strip(put(counter,best.));
run;

proc export data=want outfile='$HOME/sascommunity/want.txt' dbms=dlm;
delimiter='09'x;
run;

The resulting text file is attached.

 

buddha_d
Pyrite | Level 9

Thanks for prompt reply. I want to import the exported file to match the old one with little code difference, but I wouldn't be able to do it. both data want and have work alright. 

 

Thanks again

Kurt_Bremser
Super User

Post some lines of the input file that illustrate the effect, and the code you used. Use the proper posting method ({i}) to preserve formatting.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1762 views
  • 0 likes
  • 3 in conversation