Hello
What is the reason for getting error in the following code.
error 484
NOTE 484-185: Format $BEST was not found or could not be loaded.
How can I modify the code i order to fix the error?
***Conditional converting variable type***;
***find out if a variable is character or numeric***;
*** If it is Numeric then I need to convert it to Char;
*** If it is Char then converting is not needed***;
Data a;
input x;
cards;
111
222
333
;
run;
Data aa;
set a;
type=vtype(x);
IF type='N' then xx=compress(put(x,best12.));
else xx=compress(x);
run;
Data b;
input x $;
cards;
111
222
333
;
run;
Data bb;
set b;
type=vtype(x);
IF type='N' then xx=compress(put(x,best12.));
else xx=compress(x);
run;
Hello
I found solution but still didn't understand why the error appear.
***Conditional converting veraible type***;
***find out if a variable is character or numeric***;
*** If it is character then I need to convert it to Numeric;
*** If it is Numeric then converting is not needed***;
Data tbl1;
input snif;
cards;
111
222
333
;
run;
Data tbl1_new (drop=snif);
set tbl1;
type=vtype(snif);
IF type ne 'N' then snif_num=input(snif,3.);
/*If snif is char then we convert it to numeric*/
else snif_num=snif;
run;
Data tbl2;
input snif $;
cards;
111
222
333
;
run;
Data tbl2_new (drop=snif);
set tbl2;
type=vtype(snif);
IF type ne 'N' then snif_num=input(snif,3.);
/*If snif is char then we convert it to numeric*/
else snif_num=snif;
run;
/*https://communities.sas.com/t5/SAS-Studio/Check-variable-type-then-convert-it-to-character/td-p/427603*/
***Conditional converting varaible type***;
***find out if a variable is character or numeric***;
*** If it is Numeric then I need to convert it to Char;
*** If it is Char then converting is not needed***;
***Here we must use fnunction vvalue,which create a character version of OLDVAR***;
Data a;
input x;
cards;
111
222
333
;
run;
Data aa;
set a;
length xx $3 ;
xx=compress(vvalue(x));
drop x ;
rename xx=x;
run;
Data b;
input x $;
cards;
111
222
333
;
run;
Data bb;
set b;
length xx $3 ;
xx=compress(vvalue(x));
drop x ;
rename xx=x;
run;
Hello
I found solution but still didn't understand why the error appear.
***Conditional converting veraible type***;
***find out if a variable is character or numeric***;
*** If it is character then I need to convert it to Numeric;
*** If it is Numeric then converting is not needed***;
Data tbl1;
input snif;
cards;
111
222
333
;
run;
Data tbl1_new (drop=snif);
set tbl1;
type=vtype(snif);
IF type ne 'N' then snif_num=input(snif,3.);
/*If snif is char then we convert it to numeric*/
else snif_num=snif;
run;
Data tbl2;
input snif $;
cards;
111
222
333
;
run;
Data tbl2_new (drop=snif);
set tbl2;
type=vtype(snif);
IF type ne 'N' then snif_num=input(snif,3.);
/*If snif is char then we convert it to numeric*/
else snif_num=snif;
run;
/*https://communities.sas.com/t5/SAS-Studio/Check-variable-type-then-convert-it-to-character/td-p/427603*/
***Conditional converting varaible type***;
***find out if a variable is character or numeric***;
*** If it is Numeric then I need to convert it to Char;
*** If it is Char then converting is not needed***;
***Here we must use fnunction vvalue,which create a character version of OLDVAR***;
Data a;
input x;
cards;
111
222
333
;
run;
Data aa;
set a;
length xx $3 ;
xx=compress(vvalue(x));
drop x ;
rename xx=x;
run;
Data b;
input x $;
cards;
111
222
333
;
run;
Data bb;
set b;
length xx $3 ;
xx=compress(vvalue(x));
drop x ;
rename xx=x;
run;
When you use "input x;" and there is no other statement to define x as character type
then x is by default numeric and you can code "xx=put(x,best12.)" to covert its value to char type in xx.
When you use "input x $;" - you already defined x as character type therefor
you cannot use put function with numeric format like best.
You can check a variable type by vtype() function when you don't know its type.
It doesn't check the variable's value.
If you use the put() function, the type of the first argument determines the typeof the format. Since snif is character, SAS needs a character format, and goes looking for that, but doesn't find one.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.