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,
Can you provide some sample data?
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
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.
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
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.