Hello
I am running max of date field for each customer.
The date field is a SAS date field with format date9. and informnat date9.
The result of the max is a char with format $ATE9.
Can anyone explain how max of sas date resulted with char field??
what is $ATE9. format?
Hoe can I remove this format from the new field ?
SHOW US
We need to see your code, and also a screen capture of where you see $ATE9.
So that last variable, MAX_APPLICATION_DATE, is a character variable, not a numeric variable (dates are stored as number of days).
So rather than trying to attach a numeric format to display it as a date, you will need to create a new numeric variable to contain the actual date values as a date instead of a character string.
If it has strings that look like the screen shot then use the DATE informat to convert. If instead it has strings like YYYY-MM-DD you posted in a later reply then use the YYMMDD informat.
Here is a skeleton of a SAS data step to create a copy of your dataset and create a new date variable from the existing character variable.
data WANT;
set HAVE:
max_date = input(max_application_date,yymmdd10.);
format max_date date9.;
run;
I specifically asked to see your code, as well as screen captures.
No code, no data => helping is impossible.
@andreas_lds wrote:
No code, no data => helping is impossible.
good point, we need (a portion of) the data as well
The data is the most important part.
Removing a format is easy:
data want;
set have;
format max_ApplicationDate;
run;
In fact that's a good idea before trying to show the data.
Once you have that, show a few lines of data, as well as what you would like to be in those few lines of data. The programming will be short to create a complete fix, after you complete those steps.
I am sorry but I am not allowed to put data from work here.
However ,I have explained it very well and the answer can be theoretically.
The source field is numeric SAS date.
Then after perform max on that field I got char variable with format $ATE9.
May anyone explain what is this format $ATE9.?
I found also that even when I take distinct values of SAS numeric date then I get char variable with format $10.
/***Here the resulted variable is char!!!*/
PROC SQL;
create table wanted as
select distinct SAS_numeric_date as date
from source_data
;
QUIT;
However ,I have explained it very well and the answer can be theoretically.
NO! You haven't shown us your code that produces this unexpected result. We can't answer why you are getting unexpected results without seeing your code.
You've shown us nothing that would cause a custom format for character variables named ATE to be used. Can you show us your entire code? Why do we have to keep asking?
If SAS says something is character, then it is character. You saying it is numeric is not relevant; SAS is right in these situations. And so, the conclusion must be that the data was never numeric.
In what you have showed us, you have a character date (not a numeric date) that produces a character variable result. If you have started with a numeric variable, you would get a numeric result.
data have;
input date $10.; /* Date is character */
cards;
01-01-2020
01-02-2020
01-01-2020
;
proc sql;
create table want as
select distinct date as date /* Result is character */
from have
;
quit;
data have2;
input date :ddmmyy10.; /* Date is numeric */
format date ddmmyy10.;
cards;
01-01-2020
01-02-2020
01-01-2020
;
proc sql;
create table want2 as
select distinct date as date /* Result is numeric */
from have2
;
quit;
@Ronein wrote:
Hello
I am running max of date field for each customer.
And just how did you do that? Code please.
Since your output is character you did not use Proc Means or Summary. So one suspects macro variables stuffed into a poorly defined variable.
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.