Hello everybody,
I have numeric variables which are showed below:
SAS Output:
Checking numeric variables in the patients data set | |||||
The MEANS Procedure | |||||
Variable | Label | N | N Miss | Minimum | Maximum |
Price | Price | 21174589 | 0 | 0.85 | 4050002 |
Turnover | Turnover | 21174589 | 0 | 1 | 9.84E+08 |
Date | date | 21174589 | 0 | 17615 | 19435 |
Time | 21174589 | 0 | 30649 | 82126 |
I don't want to format variables and just want to read date and time variables of this table like hh:mm and dd:mm:yy.
How can I do that?
Thanks in advance
How much does the format of the table matter to you?
Why not just have PROC MEANS generate a dataset and then print that?
data test;
input id $ price turnover date time;
format date date9. time time5. ;
cards;
min 0.85 1 17615 30649
max 4050002 9.84E+08 19435 82126
;
proc means noprint data=test;
output out=xx ;
run;
proc print data=xx;
where _stat_='N';
format _all_;
run;
proc print data=xx;
where _stat_ in ('MIN','MAX');
run;
Obs _TYPE_ _FREQ_ _STAT_ price turnover date time 1 0 2 N 2 2 2 2 Obs _TYPE_ _FREQ_ _STAT_ price turnover date time 2 0 2 MIN 0.85 1 24MAR2008 8:30 3 0 2 MAX 4050002.00 984000000 18MAR2013 22:48
Are you asking to have PROC MEANS display the minimum date as 21Jul1969 instead of 3489?
Did you paste this table from Excel?
Just a bit of terminology so we all speak the same language:
Initial date and time variable were character were *converted* to numeric, and now you want them *formatted* to date and time.
That's done with a format statement. For example:
format DATEVAR date9. TIMEVAR time.;
How about this?
data SAMPLEDATA01;
set SAMPLEDATA;
TRD_EVENT_DT = datepart(TRD_EVENT_DT);
format TRD_EVENT_DT date9. TRD_EVENT_TM time.;
run;
Where did you see a $ in the code I posted?
$ formats are for character variables.
Or do you have a character variable?
What exactly do you have?
Provide: variable name, type, and value, for each of the 2 variables.
How much does the format of the table matter to you?
Why not just have PROC MEANS generate a dataset and then print that?
data test;
input id $ price turnover date time;
format date date9. time time5. ;
cards;
min 0.85 1 17615 30649
max 4050002 9.84E+08 19435 82126
;
proc means noprint data=test;
output out=xx ;
run;
proc print data=xx;
where _stat_='N';
format _all_;
run;
proc print data=xx;
where _stat_ in ('MIN','MAX');
run;
Obs _TYPE_ _FREQ_ _STAT_ price turnover date time 1 0 2 N 2 2 2 2 Obs _TYPE_ _FREQ_ _STAT_ price turnover date time 2 0 2 MIN 0.85 1 24MAR2008 8:30 3 0 2 MAX 4050002.00 984000000 18MAR2013 22:48
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 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.