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
Add a where clause.
where DATE < intnx('month', today(), -2, 's');
And from where know the system the variables of the two dates?
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.
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.
@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.
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.
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.
@Caro17 wrote:
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.
> 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.
>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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.