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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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