lydias
lydias

Reputation: 841

SAS: Issue with importing text parameter file using input statement

I'm importing a parameter file in txt form with no title row such as the following:

byvars             TEST16X GIO
log_transform      N
y_intercept        Y
exclude_outliers   N
exclude_einmos     N

Because it is a parameter file, the length of the two columns will not be fixed. The following is the problematic code I created to import the txt file. The two columns are concatenated instead of splitting into individual columns:

data test1;
    infile "files/parameters.txt" DELIMITER='09'x col=Colpoint
    length=linelen;
    length pname $30 pvalue $10;

    input @1 pname $ @;
    varlen=linelen - colpoint + 1;
    input pvalue $varying1024. varlen;
    call symputx('pname', STRIP(pvalue));
run;

Output: enter image description here

This parameter file defines global macro variables and their values. Such that log_transform is a macro variable with value 'N'.

Upvotes: 0

Views: 108

Answers (1)

Tom
Tom

Reputation: 51566

You seem to be working way too hard. Just use TRUNCOVER and formatted input for the PVALUE field. Use list mode input for the parameter name field.

data parameters;
  infile "files/parameters.txt" truncover ;
  input pname :$32. pvalue $200. ;
  call symputx(pname,pvalue);
run;

Upvotes: 1

Related Questions