Hi , I'am new in SAS and i'm very excited so far with this amazing and powerful program/tool.
I was wonder if any expert can help me out to get this program to work. I'am trying to use the "where" expression to find a date in a Proc Report procedure but after many web pages , I have not found my answer.here is my code so far;
Proc Report data=Bomgartestnew nowindows;
column Composante Day D__but ("Reçus" Abandon_formule M_A_D );
define Composante / group descending;
define abandon_formule /analysis sum "Hier";
rbreak after / summarize;
where Day eq "Hier"
**another option/***
Where D__but eq '01-05-2015';
***/or using a date format like 01-05-2015 because I have another variable with that kind of observations********/
Run;
It seems that I'm not doing the right thing as both "where" could not find any results and this is the error that I got;
ERROR: WHERE clause operator requires compatible variables
Hoping that someone out there can give me a hand. It would be very appreciate it.
Thanks
Francis
The two WHERE statements are failing for very different reasons.
where Day eq "Hier"
The WHERE statement is supposed to examine the incoming observations to determine which ones to use in PROC REPORT. You can't refer to a calculated field, only to pre-existing fields. Even if the field existed in the incoming data set, you would have to refer to the variable by its name (ABANDON_FORMULE), not by its label ("Hier").
Where D__but eq '01-05-2015';
SAS stores dates on a different scale that what you are expecting. It's something you will need to study at some point along the way. For now, the error message is telling you the D__but is a numeric variable and thus can't be compared to a character string. D__but probably has a format connected with it that makes it print in MMDDYY form, but its actual value is numeric. Try this version and see what happens:
Where D__but eq '05JAN2015'd;
Good luck.
The two WHERE statements are failing for very different reasons.
where Day eq "Hier"
The WHERE statement is supposed to examine the incoming observations to determine which ones to use in PROC REPORT. You can't refer to a calculated field, only to pre-existing fields. Even if the field existed in the incoming data set, you would have to refer to the variable by its name (ABANDON_FORMULE), not by its label ("Hier").
Where D__but eq '01-05-2015';
SAS stores dates on a different scale that what you are expecting. It's something you will need to study at some point along the way. For now, the error message is telling you the D__but is a numeric variable and thus can't be compared to a character string. D__but probably has a format connected with it that makes it print in MMDDYY form, but its actual value is numeric. Try this version and see what happens:
Where D__but eq '05JAN2015'd;
Good luck.
Thanks very much Astounding for the explanation and it did worked very well. Only thing that I did is that I follow your suggestion and I went back to the data set and predefined a variable with the following statement;
Data Data Bomgartestnew;
set Bomgartestnew;
Day=D__but;
If Index (D__but,'01-05-2015') Then Day="Hier";else Day="Mois";
Mois=D__but;
If Index (D__but,'05-2015') Then Mois="Mois";
Run;
So now I can use my Where expression where Day eq "Hier".
You are right I have to know more about how SAS Stores dates and I will. I've been using SAS for 3 weeks and wow this is awesome !
Thanks very Much
Assis
Post it at ODS AND REPORT Forum , since it is a question about proc report . Cynthia is there.
Thanks Xia ... I'll do it next time,
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.