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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1362 views
  • 0 likes
  • 2 in conversation