DATA Step, Macro, Functions and more

Help Me On Syntax Error

Accepted Solution Solved
Reply
Contributor
Posts: 52
Accepted Solution

Help Me On Syntax Error

Hi All,

Help me to Solve below Syntax error,

Data dirlist3;

  Set Dirlist2 ;

  command="x 'copy "||'"'||strip(file_loc)||'"  "||'"'||strip(file_to)||'"||"';";

  call execute(command);

Run;

Log Says :

685

686  Data dirlist3;

687      Set Dirlist2 ;

688          command="x 'copy "||'"'||strip(file_loc)||'"  "||'"'||strip(file_to)||'"||"';";

                                                               ----------------------

                                                               22

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

              >, ><, >=, AND, EQ, GE, GT, LE, LT, MAX, MIN, NE, NG, NL, OR, ^=, |, ||, ~=.

689      call execute(command);

690  Run;

Your Will appreciate. thanks In advance.

Regards,

Dishant Parikh


Accepted Solutions
Solution
‎05-22-2014 03:16 AM
Trusted Advisor
Posts: 3,215

Re: Help Me On Syntax Error

="x 'copy "||'"'||strip(file_loc)||'"  "'||strip(file_to)||'"'||" ';" ;
I think at this they are placed syntax correct. Probably you are needing a restart of the sas-session when you can not get out of the nesting issues.

The "magic string" could help you also. When using Eguide you will see that often as some start code.

You are trying to build an OS command. The call system interface it the one you could use within the datastep

---->-- ja karman --<-----

View solution in original post


All Replies
Trusted Advisor
Posts: 3,215

Re: Help Me On Syntax Error

you have several unbalanced apostrophes  '   "  in you statement causing the language interpreter going crazy. The first is after strip_loc. 

---->-- ja karman --<-----
Contributor
Posts: 52

Re: Help Me On Syntax Error

Jaap,

Can you please provide me Correct Syntax for above problem,because statement causing the language interpreter going crazy for me as well.

Contributor
Posts: 52

Re: Help Me On Syntax Error

Hi,

Thanks For your help,Problem solved

Solution
‎05-22-2014 03:16 AM
Trusted Advisor
Posts: 3,215

Re: Help Me On Syntax Error

="x 'copy "||'"'||strip(file_loc)||'"  "'||strip(file_to)||'"'||" ';" ;
I think at this they are placed syntax correct. Probably you are needing a restart of the sas-session when you can not get out of the nesting issues.

The "magic string" could help you also. When using Eguide you will see that often as some start code.

You are trying to build an OS command. The call system interface it the one you could use within the datastep

---->-- ja karman --<-----
Super User
Super User
Posts: 7,979

Re: Help Me On Syntax Error

Hi,

Just to add as I run into these quotes all the time, there are functions out there to help reduce the complexity of the code.  For example:

options xwait;

data tmp;

  attrib command format=$2000.;

  dir="s:\temp\rob\tmp.csv";

  dir2="s:\temp\rob\xx";

  command="x 'copy "||quote(dir)||" "||quote(dir2)||"';";

  call execute(command);

run;

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 227 views
  • 0 likes
  • 3 in conversation