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

Can anyone help to look what wrong with the program below?

I keep getting error message like

ERROR 386-185: Expecting an arithmetic expression.

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 202-322: The option or parameter is not recognized and will be ignored.


data try;
     input var1 var2 var3;
     datalines;
     7 2 2
     5 5 3
     7 2 7
;
%macro test;   %let tt=try;
data try2;
     set try;
     %bquote(dsid)=open(%str(%')&tt%str(%'));
     if varnum(%bquote(dsid),'var4') = 0 then var4 = .;
run;

%mend;
%test;

Thansk a lot!!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Then this should make your life much easier.  Switch to double quotes ... it's %str that is causing the problem:

dsid = open("&tt");

View solution in original post

4 REPLIES 4
Astounding
PROC Star

First, you have to realize that %bquote does nothing in your program.  The quoted version of the letters "dsid" is still "dsid".  Second, it is highly suspicious that you are trying to open a data set that is already open because it is mentioned in the SET statement.  What would you get if you tried this program, eliminating the confusion caused by adding macro language?

data try2;

set try;

dsid = open('try');

run;

The results may answer your other questions.

Good luck.

lizhehong
Calcite | Level 5

Thank you Astounding! this is just part of my program. I have to put a macro variable in open('&dat'). 

Astounding
PROC Star

Then this should make your life much easier.  Switch to double quotes ... it's %str that is causing the problem:

dsid = open("&tt");

lizhehong
Calcite | Level 5

The issue is solved.  I thought I have to use single quote in it :smileyblush: Thank you so much!!!!

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
  • 4 replies
  • 14203 views
  • 0 likes
  • 2 in conversation