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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Ronein
Meteorite | Level 14

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;

View solution in original post

3 REPLIES 3
Ronein
Meteorite | Level 14

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;
Shmuel
Garnet | Level 18

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.

 

 

 

 

 

Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2003 views
  • 2 likes
  • 3 in conversation