BookmarkSubscribeRSS Feed
apple
Calcite | Level 5

Using SAS EG 7.1.

 

Below is only part of my macro, but it is where the problem occurs. How do I solve it? THank you

 

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:

&MONTHF =12 and &MONTHQ=06

 

[Code]

%IF &MONTHF =12 and &MONTHQ =06 %THEN %DO;

 

%DO YEAR=&FIRSTYR %TO %eval(&LASTYR-1);

%let YEARQ = %eval(&YEAR);

data Merged&YEAR.&MONTHF;

merge

F&YEAR.&MONTHF (IN=A) QC&YEARQ.&MONTHQ(IN=B);

BY UIN;

IF A AND B Or (A AND Age=0);

run;

%END;

%END;

[/Code]

 

4 REPLIES 4
Quentin
Super User

Are &MonthF and &MonthQ resolving?  What do they resolve to?

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
apple
Calcite | Level 5
&MonthF and &MonthQ are character type. They could be 06 or 12.
Quentin
Super User
Macro variables don't have a type. They are always text. I suggest you check the values by adding a statement like %put >>&MonthF<< >>&MonthQ<<; to see what they resolve to. Or you could turn on options symbolgen.
BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Reeza
Super User

Your macro variables Year and YearQ are identical - I would recommend keeping only one. 

 

I would consider simplifying your macro's. Write a single macro that stacks or merges your datasets the way you want. Create a dataset that has the list of datasets to merge and then use call execute to execute your macro. It will be easier to debug and modify in my opinion. Obviously this is a style choice, but I find macro loops to be unwieldy at the best of times. 

 

I'm also wondering about your process...did you create all these separate monthly files, and is there a way to avoid that in the first place. This is usually why the recommendation comes to not split our data sets!

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
  • 1065 views
  • 0 likes
  • 3 in conversation