BookmarkSubscribeRSS Feed
Afor910327
Obsidian | Level 7
Good morning,

Would anyone know how could I fix this error? I am importing an excel file, and I think that is
causing some issues of character versus number, I have tried all of them character and number and it does not work.

Thanks!




MPRINT(SERIES): ********************************************************************************************************; MPRINT(SERIES): ******************************************************************************************; MPRINT(SERIES): ********************************************************************************************************; MPRINT(SERIES): data tempsas.GDPxInd_pub_total_out; MPRINT(SERIES): set tempsas.Published_GDPxInd_Output; MPRINT(SERIES): where trim(left(line)) = "1"; ERROR: Function LEFT requires a character expression as argument 1. SYMBOLGEN: Macro variable IOYEAR resolves to 1998 MPRINT(SERIES): BEA_Pub_Total_out = y1998; MPRINT(SERIES): keep BEA_Pub_Total_out; MPRINT(SERIES): run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set TEMPSAS.GDPXIND_PUB_TOTAL_OUT may be incomplete. When this step was stopped there were 0 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

 

3 REPLIES 3
Tom
Super User Tom
Super User

The error message is clear LINE is a numeric variable and you are trying to use it with a function that requires a character value.

 

What is the goal here?  Are you just trying to write a WHERE clause that will be syntactically correct whether LINE is numeric or character?

where cats(line) = "1";

You should probably fix the underlying cause that is making you unsure whether LINE is a number or a character string.  For example instead of reading Excel files have your data delivered in a agreed text format and use a data step to read it.  Then you will have control over how the dataset is created.

 

Jagadishkatam
Amethyst | Level 16
Please check the data whether line is numeric variable. if it is numeric variable then left function does not work.
Thanks,
Jag
ballardw
Super User

Note that using Proc Import to read Excel files means that same structure files can result is SAS data sets with different variable properties. So if you wrote this code to work with one imported set it may fail as you see because a variable type has changed.

Proc Import makes separate guesses for each file. And for Excel files the default number of rows to examine is small, 20 I believe. So if the content of the first 20 rows of your column named Line appears to be valid numeric values that is what you get.

 

You can search this format for Excel and Import and find many examples of such behavior.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1498 views
  • 0 likes
  • 4 in conversation