BookmarkSubscribeRSS Feed
Caro17
Calcite | Level 5

Hey,

 

I’d like to know how can I ignore the last two months with my data. The variable is a date. For example I have data from 01.01.2013 up to now and I want to see all data except the last two month, that means I want to have the data from 01.01.2013 till 23.04.2020 and I don’t want the data from 24.04.2020 till 24.06.2020 in my results. But what I don’t want to do is to change the „today date“ every time I use this query.

 

Thanx a lot for your help.

 

I am using SAS Enterprise Guide Version 7.15 HF2.

 

Caro

11 REPLIES 11
ChrisNZ
Tourmaline | Level 20

Add a where clause.

where DATE < intnx('month', today(), -2, 's');

 

Caro17
Calcite | Level 5

And from where know the system the variables of the two dates?

ChrisNZ
Tourmaline | Level 20

Please rephrase the question, I don't understand.

The today() function give today's date, and in the intnx() function goes back 2 months. Is that clearer?

Look at the documentation for these functions.

Caro17
Calcite | Level 5

Sorry! I mixed it up with another problem. It is clear so far. But now I get a syntax error (ERROR 22-322: syntax error, expect one of the following: !, !!, &, ...) and I don't know why. I have checked the syntax but I can't see a mistake.

Kurt_Bremser
Super User

@Caro17 wrote:

Sorry! I mixed it up with another problem. It is clear so far. But now I get a syntax error (ERROR 22-322: syntax error, expect one of the following: !, !!, &, ...) and I don't know why. I have checked the syntax but I can't see a mistake.


When you get messages that you can't make sense of, always (and I mean ALWAYS) post the log.

Copy/paste the whole text of the step that caused the message into a window opened with the </> button. This is necessary to keep the formatting, as the log points to the exact position where SAS could no longer make sense of your code.

Caro17
Calcite | Level 5

@Kurt_Bremser 

That's not possible because the data are on another computer. That means I can never (and I mean NEVER) copy and past the log.

Kurt_Bremser
Super User

If you do not have access to the communities from your "work" computer, then, I am afraid, you will have to retype the log as is (including all spaces!) into the </> window. I know it's tedious, but thank the idiot who forces a newbie to work in an environment where they are cut off from getting help.

 

As an alternative, I suggest you install SAS University Edition on your "internet" computer and recreate the issues there, so we can easier communicate problems and solutions.

Patrick
Opal | Level 21

@Caro17 wrote:

@Kurt_Bremser 

That's not possible because the data are on another computer. That means I can never (and I mean NEVER) copy and past the log.


I normally get around such situations by sending myself an email or if it's on a remote desktop/Citrix Servers that doesn't allow to copy/paste to my local environment then taking a screenshot from my local environment is normally still possible.

ChrisNZ
Tourmaline | Level 20

> That means I can never(and I meanNEVER)copy and past the log.
This makes no sense.

How did you see the 

ERROR 22-322: syntax error, expect one of the following: !, !!, &, ...) 

message?

 

Using SAS without seeing the log is like driving without seeing through the windshield:

You have the controls, but have no idea they are doing what you hope they are.

ChrisNZ
Tourmaline | Level 20

>and I don't know why. I have checked the syntax but I can't see a mistake.

How do you expect us to see mistakes in code we don't see?

@Kurt_Bremser's comments are patently sensible.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 2637 views
  • 0 likes
  • 4 in conversation