hi guys,
i dont understand the bold commands below.Shouldn't that be INPUT instead?
Please someone explain to me
PROC FORMAT;
VALUE $GENDER 'F','M' = 'Valid'
' ' = 'Missing'
OTHER = 'Miscoded';
VALUE $DX '001' - '999' = 'Valid'
' ' = 'Missing'
OTHER = 'Miscoded';
VALUE $AE '0','1' = 'Valid'
' ' = 'Missing'
OTHER = 'Miscoded';
RUN;
DATA _NULL_;
INFILE "C:\CLEANING\PATIENTS.TXT" PAD;
FILE PRINT; ***Send output to the output window;
TITLE "Listing of Invalid Patient Numbers and Data Values";
***Note: We will only input those variables of interest;
INPUT @1 PATNO $3.
@4 GENDER $1.
@24 DX $3.
@27 AE $1.;
IF PUT(GENDER,$GENDER.) = 'Miscoded' THEN PUT PATNO= GENDER=;
IF PUT(DX,$DX.) = 'Miscoded' THEN PUT PATNO= DX=;
IF PUT(AE,$AE.) = 'Miscoded' THEN PUT PATNO= AE=;
RUN;
PUT(<var>, <format>) is a function that transforms the internal value of <var> into a string using the format <format>, INPUT(<string>,<informat>) transforms <string> into an internal value using input format <informat>. Not to be confused with the PUT and INPUT statements which are commands that do not return a value.
PG
PUT(<var>, <format>) is a function that transforms the internal value of <var> into a string using the format <format>, INPUT(<string>,<informat>) transforms <string> into an internal value using input format <informat>. Not to be confused with the PUT and INPUT statements which are commands that do not return a value.
PG
You can use INPUT( ) in this case but then the formats need to be defined as informats.
PROC FORMAT;
INVALUE $GENDER 'F','M' = 'Valid'
' ' = 'Missing'
OTHER = 'Miscoded';
INVALUE $DX '001' - '999' = 'Valid'
' ' = 'Missing'
OTHER = 'Miscoded';
INVALUE $AE '0','1' = 'Valid'
' ' = 'Missing'
OTHER = 'Miscoded';
RUN;
DATA _NULL_;
INFILE "C:\CLEANING\PATIENTS.TXT" PAD;
FILE PRINT; ***Send output to the output window;
TITLE "Listing of Invalid Patient Numbers and Data Values";
***Note: We will only input those variables of interest;
INPUT @1 PATNO $3.
@4 GENDER $1.
@24 DX $3.
@27 AE $1.;
IF INPUT(GENDER,$GENDER.) = 'Miscoded' THEN PUT PATNO= GENDER=;
IF INPUT(DX,$DX.) = 'Miscoded' THEN PUT PATNO= DX=;
IF INPUT(AE,$AE.) = 'Miscoded' THEN PUT PATNO= AE=;
RUN;
But most of us would not bother.
Key thing to remember: PUT( ) accepts numeric or string arguments, but always returns a string value
INPUT( ) always requires a string argument, but can return a numeric or string return value, based on the informat.
Richard in Oz
oh so this just answered my 2nd question to PG.
Thank you both
So both functions can be used to convert a string value into another string value. but neither can be used to convert a numeric value to another numeric value. if you ever need to do that you would have to concatenate, using a format that returns a string that looks like a number,
new_newmeric = input(put(prev_number, somefmt.), best.) ;
Richard in Oz
sorry do you by "transforms the internal value of <var> into a string" mean converts the numeric value of var into a char value? All i know about put and input is that the first converts numeric to char using a certain format and the latter the other way around
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.