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

Below code is resolving the values of va and vb but not able to excute input function in below code:

 

data temp;

set tmp(keep=&keep_full_lst.);

array vars {*} a1-a&count.;

do i = 1 to &count.;

va=symget('VARS'||left(i));

vb=symget('VARFMT'||left(i));

put vb;

vars{i} = put(input(va,vb),50.);

end;

drop i va vb;

run;

 

Failing :

ERROR 85-322: Expecting a format name.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The input() function expects a format name as its second argument, not a character expression that results in a format name. Use the inputn() (or inputc() for character) instead. These functions expect a character expression as second argument.

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

The input() function expects a format name as its second argument, not a character expression that results in a format name. Use the inputn() (or inputc() for character) instead. These functions expect a character expression as second argument.

swwithsas
Fluorite | Level 6

It is not throwing error now but not even displaying any values:

 

data temp;

set tmp(keep=&keep_full_lst.);

array vars {*} a1-a&count.;

do i = 1 to &count.;

va=symget('VARS'||left(i));

vb=symget('VARFMT'||left(i));

put va vb;

 

vars{i} = putc(va,vb);

end;

drop i va vb;

run;

 

All the vars variables are '.'

 

Kurt_Bremser
Super User

You used putc, which creates character values, but did not create the array as character. You will find NOTEs about the conversions and invalid values in the log.

Expand your array statement:

array vars {*} $ 10 a1-a&count.;

You may have to adapt the length.

swwithsas
Fluorite | Level 6

Thanks. Sorry for silly questions. I have another one.

 

data temp;

set tmp(keep=&keep_full_lst.);

array vars {*} $ 50 a1-a&count.;

do i = 1 to &count.;

va=symget('VARS'||left(i));

vb=symget('VARFMT'||left(i));

put va vb;

 

vars{i} = putc(va,vb);

end;

drop i va vb;

run;

 

This worked by adding $ and length, BUT, it should apply format on the column names resolved by "va". It is just printing the va values for each row of the dataset tmp.

Kurt_Bremser
Super User

If you want to asssign formats to columns, you do that in proc datasets, and you need to dynamically create the code for that from your data source that contains the variable-format name/value pairs.

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
  • 5 replies
  • 7132 views
  • 3 likes
  • 2 in conversation