New to SAS: How to Input and Manipulate a .txt File

Posts: 1

New to SAS: How to Input and Manipulate a .txt File

I have a data file that I am trying to import into SAS that looks something like the below (where I have replaced data that was not collected with a '.'):

WCM2B W C M 2 B M.B 2 18.4 12.3 g

WCM2B W C M 2 B M.B 2 19.2 12.3 g

WCM2B W C M 2 B S.P 2 19.5 .       .

WCM2B W C M 2 B Z.G 2 17.7 10.7 g

WCM2B W C M 2 B Z.G 2 18.4 10.7 g

WCM2B W C M 2 B Z.G 2 17.6 10.8 g

WCM2B W C M 2 B Z.G 2 20.1 12.1 g

There are headings for each of these columns, some of which list categorical variables, and some of which do not.

My questions:

1) What is the proper code for ensuring a text file like this, delimited by spaces as shown above and with ~36 rows and 11 columns of data is properly formatted in SAS? How can I then perform operations on this data so that it comes up in the output window? Even the most basic procedure to do on some chosen infile would do. Ideally, if someone is feeling very generous I am trying to get an understanding of how to do regression analysis including analyzing residuals and standard statistics.

2) Do I need to change categorical variables into binary for it to properly analyze the data?

3) Are there any other issues with this data I'm missing that might make prevent it from working?

Thank you very much for your time.  I have very little programming experience so getting all the syntax down is quite difficult for me.

Respected Advisor
Posts: 3,894

Re: New to SAS: How to Input and Manipulate a .txt File

You need some sort of training to use SAS. May be best for you is to start with SAS Enterprise Guide (SAS EG).

EG has a lot of wizards which help you solve your tasks. There is for example a Import Wizard which would support you in reading your text file and convert it into a SAS dataset (this is the first thing you need to do).


Once the data is available as a SAS dataset there are a lot of wizards available - also for Regression analysis. This will get you started.


SAS is a very powerfull language and Wizards cover only part of the functionality. Once you dive into the details and you need special things not covered by Wizards you will have to build up some understanding of SAS coding.

N.B: SAS is licensed by module - so only because you can see a task in EG doesn't necessarily mean that you can also use it. A lot of the functionality comes with the base module which you always will have (Base SAS aka SAS Foundation). Other stuff like part of the regression tasks will be available via SAS/Stats - so this will only work if this module is licensed. The same is true for "Time Series" - this is SAS/ETS... and so on.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation