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

Hi everyone!

I got a problem trying to imprort data from .tsv text file to SAS Base. I used the script in one of the previous versions and everything was okay but now when I got SAS 9.4 I get an odd result.

The initial source of data is text file with only one column. Here is a sample of data file:

TRANS_SUM
2286,5
985,39
3730,23
984,12

To import data I submit the script below:

Data TRANS.Test_data (Compress = yes);

  Retain TRANS_SUM;

   Infile 'h:\sample2.tsv'

   DLM = '09'x MISSOVER DSD FIRSTOBS = 2;

   Input

  TRANS_SUM_RUR CommaX20.;

   Format

  TRANS_SUM_RUR Comma20.2;

Run;

Earlier I got a dataset with one column and for records of decimal numbers with decimal part separated by comma.

TRANS_SUM
2286.5
985.39
3730.23
984.12

But now a dataset is being created but I get missing values instead.

TRANS_SUM
.
.
.
.

Would you be so king to explain me what's wrong with the script.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

First, why would you use the MISSOVER option instead of the TRUNCOVER option?  The only difference is that with MISSOVER if you try to read 20 characters and there are 6 available then SAS sets the value to missing. With TRUNOVER is just reads the 6 characters that are there.

Second don't use formatted input when the widths of the fields vary (at least not without adding : or other modifiers) to prevent SAS from reading past the end of the field and getting the column pointer confused.

Third SAS code files are called programs not scripts.  SAS is a language not a shell. Smiley Happy

data trans.test_data (compress = yes);

   infile 'h:\sample2.tsv'

      dlm = '09'x truncover dsd firstobs = 2

   ;

   informat trans_sum_rur commax20.;

   format trans_sum_rur comma20.2;

   input trans_sum_rur ;

run;


View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

First, why would you use the MISSOVER option instead of the TRUNCOVER option?  The only difference is that with MISSOVER if you try to read 20 characters and there are 6 available then SAS sets the value to missing. With TRUNOVER is just reads the 6 characters that are there.

Second don't use formatted input when the widths of the fields vary (at least not without adding : or other modifiers) to prevent SAS from reading past the end of the field and getting the column pointer confused.

Third SAS code files are called programs not scripts.  SAS is a language not a shell. Smiley Happy

data trans.test_data (compress = yes);

   infile 'h:\sample2.tsv'

      dlm = '09'x truncover dsd firstobs = 2

   ;

   informat trans_sum_rur commax20.;

   format trans_sum_rur comma20.2;

   input trans_sum_rur ;

run;


V_Andy
Fluorite | Level 6

Thank you very much, Tom! It helped and of course this is not a script, this is a program!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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