BookmarkSubscribeRSS Feed
Harpal_09
Calcite | Level 5

I wrote this code but its not running its showing some errors which is mentioned below the written code.

 

Proc Import datafile="F:\Kaggle\Titanic.xlsx" out=Titatnic_Worksheet DBMS= excel Replace Getnames=Yes; 
Run;

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ERROR 22-322: Syntax error, expecting one of the following: ;, DATAFILE, DATATABLE, DBMS, FILE, OUT, REPLACE, TABLE. ERROR 76-322: Syntax error, statement will be ignored. 242 Run;

3 REPLIES 3
art297
Opal | Level 21

You're missing a semi-colon after the option REPLACE. Also, DBMS=excel may or may not work for you. You may want to use DBMS=XLSX

 

Art, CEO, AnalystFinder.com

rogerjdeangelis
Barite | Level 11
I find it useful to run this first

libname des "F:\Kaggle\Titanic.xlsx";
proc contents data=des._all_;
run;quit;
libname des clear;
ballardw
Super User

When posting an error message to the forum there are two things you can do that will help provide answers. First is to include the code that generated the error along with the actual error. Best is the entire procedure or data step. Second is to paste it into a code box opened with the forum {i} menu item.

Error messages often include an _ indicating the position of the reported error. When you paste the  log into the main message window then the forum reformats the message losing some of the diagnostic informations.

 

Compare:

126 data exp;

127 a='i will try to removie spl char @ and another spl $'

128 a1=translate (a,'','@$' );

--

22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=,

<>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,

|, ||, ~=.

129 run;

with

126  data exp;
127     a='i will try to removie spl char @ and another spl $'
128     a1=translate (a,'','@$' );
        --
        22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=,
              <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,
              |, ||, ~=.

129  run;

In the code box you can see that the undescores appear under the a1 which is not obvious from the previos. In this case I would look at ther previous line and note a missing semicolon.

 

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 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
  • 1088 views
  • 0 likes
  • 4 in conversation