Help using Base SAS procedures


Not applicable
Posts: 0



I'm am reletively new to SAS and i am trying to write some code to split up a character string and import it into a table. Most of what i have done works ok but i am having problems with the following:

Username = scan(_blob_,1,",")
Balance = scan(_blob_,2,",");
Pending_bonus_balance = scan(_blob_,3,",");
Bonus_balance = scan(_blob_,4,",");
Total_bonus = scan(_blob_,5,",");
Poker_nickname = scan(_blob_,6,",");
Has_played_poker_download = scan(_blob_,7,",");
Last_bonus = scan(_blob_,8,",");
Last_bonus_date = scan(_blob_,9,",");
Poker_rakes = scan(_blob_,10,",");

The file that i am reading from contains a few thousend rows like this:

The problem comes when its gets to the ,, fields. It ignores the fact that it is empty and just pushes everything along one column. I have tried writing IF statements to fill the empty cells but that did not help.

Help anyone?

Not applicable
Posts: 0

Re: Scan

Posted in reply to deleted_user
instead of SCAN() it sounds like you want to look at how the INFILE and INPUT statements can help you. A very significant feature is the DSD option of the INFILE statement

good luck

Not applicable
Posts: 0

Re: Scan

Posted in reply to deleted_user
Welcome to the wonderful (full of wonder) rich world of SAS and SAS programming.
SAS was originally written for non-programmers, so there is generally an easy or easier way of doing things.

You are doing this the hard way.

The easy way is
DATA captured;
INFILE indata delimiter=',' dsd;

INPUT Username balance pending_bonus_balance total_bonus poker_nickname has_played_poker_download last_bonus last_bonus_date poker_rates;
This code example is not perfect, I haven't tested it.
Find the Web online documentation for BaseSAS for 9.1.x or your version of SAS and begin reading.

SAS is not your normal programming language. It is data centric and meant to simplify the programming process of reading data in, processing the data, and reporting on the results of the processing. It is very rich in features, it is so extensive, I expect no one knows all of it in complete detail.
Ask a Question
Discussion stats
  • 2 replies
  • 1 in conversation