BookmarkSubscribeRSS Feed
qinghe
Fluorite | Level 6

Hi, 

 

I want to know how to solve the error " Invalid value for width specified" in the following program:

data A;
input record_id name $ mark;
cards;
1100111 A 99
1100112 B 78
2100111 C 60
2100100 D 78
2100112 E 91
3100111 F 40
3011112 G 36
;

data B (rename=(record_id=start));
retain fmtname "select" label "A";
set test;
where mod(record_id,10) in (0, 1);
run;

proc format cntlin=B;
run;

proc sql;
create table A_selected as
select * from test
where put(record_id, select.)="A";
quit;

 

I can get the correct output, but with error messages.

 

Thank you in advance.

 

Qinghe

3 REPLIES 3
qinghe
Fluorite | Level 6

Hi, 

 

I am sorry that there is a typo in the program:

 

"select * from test" should be "select * from A"

 

Regards,

Qinghe

FreelanceReinh
Jade | Level 19

Hello @qinghe,

 

To avoid the error message, specify a sufficient default length (such as 7 characters if this is the maximum number of digits in the RECORD_ID values) for your format:

retain fmtname "select" label "A" default 7;

Without this specification the default length is 1, which is insufficient to write the RECORD_IDs which are not classified as "A", hence the error message.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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