BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5


proc format ;
invalue $sex 'F'='female' 'M'='male';
run;

data s ;
set sashelp.class ;
gender=put(sex,$sex.) ;
run;

it doesn't give data 

is there any mistake please let me know

6 REPLIES 6
thanikondharish
Calcite | Level 5

proc format ;
invalue age 11=100 12=200 13=300 14=400 15=500 16=600 ;
run;

data s ;
set sashelp.class ;
new_age=input(age,age.) ;
run;

 

when i run above program it gives values but it shows note like see below

Capture1.PNG

thanikondharish
Calcite | Level 5

proc format ;
invalue age 11=100 12=200 13=300 14=400 15=500 16=600 ;
run;

data s ;
set sashelp.class ;
new_age=input(age,age.) ;
run;

 

when i run above program it gives data but show not log window like see below photo

Capture.PNG

Kurt_Bremser
Super User

The input()function expects a string as its first argument, so SAS needs to convert the numeric age to character first.

To avoid the message, add a put() inside the input() to explicitly convert age.

ballardw
Super User

@thanikondharish wrote:

proc format ;
invalue age 11=100 12=200 13=300 14=400 15=500 16=600 ;
run;

data s ;
set sashelp.class ;
new_age=input(age,age.) ;
run;

 

when i run above program it gives values but it shows note like see below

Capture1.PNG


If you ever read the documentation for the INPUT function you would know that the first parameter is expected to be character values.

Since you have used INPUT with a numeric variable AGE in the position where it expects character values then SAS tries to help by converting the numeric variable to character to do what you attempt. And then it places the note in the LOG to tell you that may have done something you did not expect with the implication that the result might not quite be what you expect.

Tom
Super User Tom
Super User

Formats are for converting values to text and informats for converting text to values.

You use formats with PUT statement and PUT() function.

You use informats with INPUT statement and INPUT() function.

You need to either define a FORMAT instead of INFORMAT, or use the INPUT() instead of the PUT() function.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

You have two responses to the question answering it, please go ahead and mark one as correct and close the topic - in fact all of your questions on here are still unanswered, please close them out.

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 957 views
  • 0 likes
  • 5 in conversation