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

The following is the raw data set in a txt file , suppose there are two variable , one is named ID, the other is named Name . I want to read the data set , how should I do ? Thank you.

1 Nay Rong
2 Kelly Windsor
3 Julio Meraz
4 Richard Krabill

1 ACCEPTED SOLUTION

Accepted Solutions
tianerhu
Pyrite | Level 9

data ABC;
infile datalines;
input ID
Name&:$15.;
datalines;
1 Nay Rong
2 Kelly Windsor
3 Julio Meraz
4 Richard Krabill
;
run;
proc print data = ABC noobs;
run;

View solution in original post

6 REPLIES 6
Reeza
Super User

This works for me:

 

data have;
infile cards;
input ID Name $50.;
cards;
1 Nay Rong
2 Kelly Windsor
3 Julio Meraz
4 Richard Krabill
;;;;
run;

@tianerhu wrote:

The following is the raw data set in a txt file , suppose there are two variable , one is named ID, the other is named Name . I want to read the data set , how should I do ? Thank you.

1 Nay Rong
2 Kelly Windsor
3 Julio Meraz
4 Richard Krabill


 

tianerhu
Pyrite | Level 9

tianerhu_0-1615928263010.png

Thank you. But it doesn't work.

above is the result.

 

Reeza
Super User
Then something is different than what you posted. Please upload a sample of your actual file or make sure to post your data using the code block. Otherwise HTML screens will often strip away characters (tabs) that could be important to your data.

It would also help to show your log and code because the code I provided wouldn't have generated anything like that and I don't know which output I should even be looking at.

tianerhu
Pyrite | Level 9

I have sloved it . Thank you very much.

Reeza
Super User
Then please update the post with the correct solution for others and mark it as solved.
tianerhu
Pyrite | Level 9

data ABC;
infile datalines;
input ID
Name&:$15.;
datalines;
1 Nay Rong
2 Kelly Windsor
3 Julio Meraz
4 Richard Krabill
;
run;
proc print data = ABC noobs;
run;

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