BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

@Emoji wrote:

Variable Market is a variable (string) from Work.my_old_table. By using Market = XXX, I was trying to say that the when String market is XXX (in reality it is something like 'market_data', the rest of the code should be executed.

I ran the code that you shared and got the following error:

 

49 date = intnx('qtr','01jan2022'd,qtr-1,'b') to intnx('qtr','01jan2022'd,qtr-1,'e');
__
22
2 The SAS System 06:13 Tuesday, December 13, 2022

202
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT,
IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.

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

  


To test a variable's value you need to use SAS code, not MACRO code.

 

There is no way that the code I posted would produce that message. 

It looks like you removed the DO keyword from the DO loop.

The syntax for an iterative DO loop is 

do <varname> = <initial value> [to <final_value>] [ by <increment> ] ;
PaigeMiller
Diamond | Level 26

You don't state what this code is supposed to be doing, and it is always helpful to state what the code is supposed to be doing.

 

It looks like you are trying to compute the number of days in a quarter by using a loop, and it was already explained in your earlier thread that loops are not needed to do this.

 

So that's my guess anyway. Regardless, tell us the purpose of this code, tell us what it is supposed to be doing. Whatever the purpose, you have adopted a very difficult approach to get this done, and if we only knew what you were doing, I'm sure many people could suggest simpler and faster ways to do what you want.

--
Paige Miller
Reeza
Super User

I like @Patrick's second solution.

 

data my_new_table;
set my_old_table; format date date9.; if market = "xxxx" then do date = '01jan2022'd to '31dec2022'd; qtr=qtr(date); output; end; run;

You say you want to calculate the number of days in each quarter but don't show how it's used. 

 

If after all this you still do not have a solution that works, I would suggest taking a step back as this is definitely an xy problem.

Rather than posting your non working code, please show us a small sample of your input data and what you want as output instead. 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 17 replies
  • 1024 views
  • 4 likes
  • 7 in conversation