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.

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
  • 5 replies
  • 816 views
  • 0 likes
  • 3 in conversation