SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

INPUT function requires a character argument

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 88
Accepted Solution

INPUT function requires a character argument

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;

 

 


Accepted Solutions
Solution
‎12-13-2017 10:44 AM
SAS Employee
Posts: 33

Re: INPUT function requires a character argument

Posted in reply to christinagting0

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?

View solution in original post


All Replies
Esteemed Advisor
Posts: 5,474

Re: INPUT function requires a character argument

Posted in reply to christinagting0

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.

PG
Solution
‎12-13-2017 10:44 AM
SAS Employee
Posts: 33

Re: INPUT function requires a character argument

Posted in reply to christinagting0

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?

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 3008 views
  • 0 likes
  • 3 in conversation