Why am I getting this error?
INPUT function requires a character argument
Doesn't input function create numerical variables? Why is it saying that it needs a character argument?
Here is my code:
proc sql; create table hk_dados1 as select subject_id as id, MRN, BASELINE_DOC, COLLECTION_CENTER as site_ca, BASELINE_DOB, BASELINE_AGE, BASELINE_SEX, BASELINE_MARITALSTATUS, BASELINE_EDUCATION, BASELINE_COUNTRYORIGIN, BASELINE_IMMIGRATIONDATE, BASELINE_LANGUAGES, BASELINE_ENGLISH, BASELINE_DOA, BASELINE_TIMEOFINJURYSTATUS, BASELINE_ATTEMPTEDRETURN, BASELINE_CURRENTWORKING, BASELINE_HTN, BASELINE_DIABETES, BASELINE_MENTAL, BASELINE_SCORE as BASELINE_PHQ_SCORE, BASELINE_SMOKER, BASELINE_ANNOY, BASELINE_GUILTY, BASELINE_EYEOPENER, BASELINE_NPRSHIP, BASELINE_NPRSKNEE, BASELINE_SF1, BASELINE_TOTAL as BASELINE_PCS_TOTAL, BASELINE_WTOTALSCORE, DISCHARGE_DOC, input(DISCHARGE_DC_SITE,1.) as discharge_site, input(DISCHARGE_STREAM,1.) as discharge_stm, input(DISCHARGE_HR_RECOVERING,1.) as discharge_hr_recover, input(DISCHARGE_HR_HELPFUL,1.) as discharge_hr_help, input(DISCHARGE_HR_SATISFACTION,1.) as discharge_hr_sat, input(DISCHARGE_HR_GENHEALTH,1.) as discharge_hr_genhel, input(DISCHARGE_WTOTALSCORE, 2.) as discharge_womac_score, input(DISCHARGE_SCORE,2.) as discharge_phq, input (DISCHARGE_NPRSHIP, 2.) as discharge_npr_bn, input (DISCHARGE_NPRSKNEE, 2.) as discharge_npr_kn, input (DISCHARGE_TOTAL, 3.) as discharge_pcs, DISCHARGE_RTW_STATUS from temp.'All$'n; quit;
The first argument of the INPUT function must be character and the second argument specifies an informat that you wish to use to read that character value. This function returns a NUMERIC when you use a numeric informat and it returns a character value if the informat is CHARACTER. It is most often used to convert character values to numeric but it can also be used to apply a character informat to transform the original character value into a different character value.
In your case (and as PGStats indicates) you do not need to convert to numeric if your original value is already numeric. What is the original numeric value and do you need to transform it in some way?
In your code, INPUT transforms character strings into numbers.
In the code
result = INPUT(arg1, arg2);
arg1 must be a character string. If arg1 is already a number, you don't need to call INPUT.
The first argument of the INPUT function must be character and the second argument specifies an informat that you wish to use to read that character value. This function returns a NUMERIC when you use a numeric informat and it returns a character value if the informat is CHARACTER. It is most often used to convert character values to numeric but it can also be used to apply a character informat to transform the original character value into a different character value.
In your case (and as PGStats indicates) you do not need to convert to numeric if your original value is already numeric. What is the original numeric value and do you need to transform it in some way?
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.