BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DavidGhan
SAS Employee

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

2 REPLIES 2
PGStats
Opal | Level 21

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
DavidGhan
SAS Employee

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?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

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.

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