Hi,
Attached is the "president.txt" file.
I need to assign appropriate format to DOB (5th column), votes (7th column), and PercVote (8th column).
Here is my code.
Could anyone help me to correct the code? Thanks a lot.
filename TXTfile '/folders/myfolders/Assignment 2/President.txt';
data President;
infile TXTfile missover;
input FullName & $22.
City $19.
State $20.
ASP 2.
DOB mmddyy10.
Term 4.
Votes comma10.
PercVote percent10.;
format DOB mmddyy10. Votes comma10. PercVote percent10.;
run;
proc print data = President;
run;
I copied your file to my UE, and ran this code with success:
data test;
infile '/folders/myfolders/President.txt' expandtabs lrecl=300 truncover;
input
@1 FullName $22.
@25 City $19.
@49 State & $20.
ASP :2.
DOB :mmddyy10.
Term :4.
Votes :comma10.
PercVote :percent10.
;
format DOB mmddyy10. Votes comma10. PercVote percent10.;
run;
I copied your file to my UE, and ran this code with success:
data test;
infile '/folders/myfolders/President.txt' expandtabs lrecl=300 truncover;
input
@1 FullName $22.
@25 City $19.
@49 State & $20.
ASP :2.
DOB :mmddyy10.
Term :4.
Votes :comma10.
PercVote :percent10.
;
format DOB mmddyy10. Votes comma10. PercVote percent10.;
run;
I ran successfully too. Thanks a lot.
Please feel free to ask about details if something is unclear.
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.