Hello,
I use SAS GUIDE and i want to classify datas by month.
My table is Janv-15 to dec-15...or SAS class by alphabet instead or chronologic...it put avril then august insteal of janvier, février...
What do i have to do?
Thanks
Since there is no NLS informat that can read the MMMM_YY format that you get, you will have to translate manually be converting the french name to a number, and then use a standard format:
data want;
input date_french $;
format date date9.;
date_french = tranwrd(date_french,'janv','01');
date_french = tranwrd(date_french,'fevr','02');
date = input('01-'!!date_french,ddmmyy8.);
cards;
janv-15
fevr-15
;
run;
You either have your dates stored as character instead of as SAS date values, or you're sorting by formatted instead of raw values.
Hello, here is my table...how can i put this by chronology?
Make sure your dates are SAS dates, so numeric with a date format. Then they'll sort correctly. You may need t create a new variable to do this using INPUT function.
@Reeza, thanks, i do this but problem :
3 PROC SQL NOEXEC;
4 SELECT /* mois num */
5 (INPUT(t1.MOIS,CATDFMY)) AS 'mois num'n
_______
22
76
ERROR 22-322: Syntax error, expecting one of the following: un nom de format, ?.
ERROR 76-322: Syntax error, statement will be ignored.
6 FROM WORK.TABLE_DES_MOIS1 t1;
7 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 secondes
cpu time 0.00 secondes
8 QUIT; RUN;
9
here is my table
01/01/2015 janv.-15
02/01/2015 janv.-15
03/01/2015 janv.-15
04/01/2015 janv.-15
05/01/2015 janv.-15
06/01/2015 janv.-15
07/01/2015 janv.-15
08/01/2015 janv.-15
09/01/2015 janv.-15
10/01/2015 janv.-15
11/01/2015 janv.-15
12/01/2015 janv.-15
13/01/2015 janv.-15
14/01/2015 janv.-15
15/01/2015 janv.-15
data work.new;
set WORK.TABLE_DES_MOIS1;
mois_num = input(MOIS,ddmmyy10.);
run;
Don't forget the dot when using a format.
@Kurt, thanks but it gimes now
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 PROC SQL NOEXEC;
4 SELECT /* Mois NUM */
5 (Mois_Num = INPUT(t1.MOIS,ddmmyy10.)) AS 'Mois NUM'n
6 FROM WORK.TABLE_DES_MOIS1 t1;
ERROR: The following columns were not found in the contributing tables: Mois_Num.
7 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 secondes
cpu time 0.00 secondes
8 QUIT; RUN;
It would be well worth reading this for background.
Your calculation s mixing data step and SQL.
Input(..) as 'mois num'n
No = or variable name before the Input.
@Reeza, in fact!!
I make a modification
INPUT(t1.MOIS,monyy5.)
But it gives me "."
. 01/01/2015 janv.-15
. 02/01/2015 janv.-15
. 03/01/2015 janv.-15
. 04/01/2015 janv.-15
. 05/01/2015 janv.-15
. 06/01/2015 janv.-15
@peter2 wrote:
@Reeza, in fact!!
I make a modification
INPUT(t1.MOIS,monyy5.)
But it gives me "."
. 01/01/2015 janv.-15
. 02/01/2015 janv.-15
. 03/01/2015 janv.-15
. 04/01/2015 janv.-15
. 05/01/2015 janv.-15
. 06/01/2015 janv.-15
monyy. is a standard SAS format and expects English month abbreviations.
For the second column, use ddmmyy10.
in fact, i have OCT2015 & NOV2015....but not for the other month, why?
Up to now, you only posted example data for January. Providing more complete example data will make it easier for us to help you.
What exactly IS the rule for building your target variable, and what values should it contain? Keep in mind that a SAS date value is a count of the number of days since 01/01/1960 and will always contain a "day part".
You need to write correct SQL code, of course. I gave you a data step.
proc sql;
select
input(t1.mois,ddmmyy10.) as mois_num
from work.table_des_mois t1
;
quit;
Note that I deliberately do not use blanks in variable (or other) names, as they are only a major pain-in-the-ass.
thank you all...
@Kurt, here is what i obtain
. 25/09/2016 sept.-16
. 26/09/2016 sept.-16
. 27/09/2016 sept.-16
. 28/09/2016 sept.-16
. 29/09/2016 sept.-16
. 30/09/2016 sept.-16
OCT2016 01/10/2016 oct.-16
OCT2016 02/10/2016 oct.-16
OCT2016 03/10/2016 oct.-16
OCT2016 04/10/2016 oct.-16
OCT2016 05/10/2016 oct.-16
OCT2016 06/10/2016 oct.-16
OCT2016 07/10/2016 oct.-16
what i want is to get in the first row all months like OCT2016 in the aim to class by chronology.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.