I have two files with some data.
file1.txt
123
456
789
100
file2.txt
ABC
I want output file file3.txt as:-
123ABC
456ABC
789ABC
100ABC
How can i do this?
one way
data file1;
input numVar;
datalines;
123
456
789
100
;
data file2;
charVar="ABC";
run;
proc sql;
create table file3 as
select cats(numVar, charVar) as newVar
from file1, file2;
quit;
one way
data file1;
input numVar;
datalines;
123
456
789
100
;
data file2;
charVar="ABC";
run;
proc sql;
create table file3 as
select cats(numVar, charVar) as newVar
from file1, file2;
quit;
Btw, do you want to output this as a TXT file?
And are file1 and file2 SAS data sets?
You mean that your output should be in a TXT file?
You can do something like this with a data step
data _null_;
set file3;
file "MyPath\MyFile.txt";
put newVar;
run;
Or alternatively PROC EXPORT to export the file
The INFILE and FILE statements actually require complete paths, not just the file name itself:
data _null_;
infile "file2.txt";
input part2 $;
infile "file1.txt" end=done;
file "file3.txt" noprint;
do until (done);
input part1 $;
put part1 +(-1) part2;
end;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.