BookmarkSubscribeRSS Feed
Sherryfu0315
Calcite | Level 5

Hi,

 

I am given a data set on how satisfaction depends on race, gender, age and regional location. However, the format of the txt. file is like below:

 

Capture.JPG

 

It looks like a formatted summary table. I am wondering how can I input these data into SAS? I would like to have five variables: satisfaction, gender, race, region and age.

 

Thanks a lot!

 

Best,

Sherry 

1 REPLY 1
Reeza
Super User

It looks to be column delimited so you could read it in as column formatted, something like the following to get you started. 

A data step is the best approach. 

 

infile '../cda.txt' firstobs=7;
input @1 region $ @20 White_lt35_M @27 White_lt35_F .... etc;

And if it's a single data set that you need to read, and only once, there's no issue with copying it to Excel, reformatting and then exporting it back as a CSV and importing that. You run the risk of adding errors but it's easy to check with a small data set.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 583 views
  • 0 likes
  • 2 in conversation