BookmarkSubscribeRSS Feed
RajasekharReddy
Fluorite | Level 6

Hello ,

 

I am using PUT & INPUT function so long and using below like

 

xx=put(aa,?best.)

zz=input(bb,??best.)

 

May i know why we are using "?" in put & input function and what is difference with out "?" and with "?"

 

Thank you in advance.

 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

The INPUT Function Documentation says:

 

? or ??

specifies the optional question mark (?) and double question mark (??) modifiers that suppress the printing of notes and input lines when invalid data values are read. The ? modifier suppresses the invalid data message. The ?? modifier suppresses the invalid data message and prevents the automatic variable _ERROR_ from being set to 1 when invalid data is read.

ballardw
Super User

An example use case: Data being read has a date field in mm/dd/yyyy format but missing values where the data was not recorded are represented by 99/99/9999.

Since you know that values will be invalid dates and actually represent missing data when the values are read you will be okay with SAS variables with missing values but you may not want to wade through a bunch of junk in the log for a know data issue. So a data step to read the example data uses the ?? modifier as follows:

 

data example;
   input x ??mmddyy10.;
   format x mmddyy10.;
datalines;
01/01/2019
99/99/9999
;
run;

remove the ?? and replace with either a single ? or nothing to see the different behaviors.

 

Reading a field that should be numeric but sometimes has NA or other not entered or not available code would be another similar use.

 

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 25. 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
  • 3 replies
  • 721 views
  • 0 likes
  • 4 in conversation