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
Hi,
I am sorry that there is a typo in the program:
"select * from test" should be "select * from A"
Regards,
Qinghe
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.
Thanks a lot. It's very helpful!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.