BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KyuL
Calcite | Level 5

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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;
KyuL
Calcite | Level 5

I ran successfully too. Thanks a lot.

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