New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chinna0369
Pyrite | Level 9

Hi, 

 

below is my data:

snip 1.PNG

 

I want to create above dates in ISO date format like 2019-02-28 & 2019-03-18.

 

Could you please help me with this. 

 

Thanks,

Adithya

1 ACCEPTED SOLUTION

Accepted Solutions
chinna0369
Pyrite | Level 9
Got it below is my code:
want=input(AESTDAT_RAW,anydtdte20.);
format want yymmdd10.;
Thanks!

View solution in original post

8 REPLIES 8
chinna0369
Pyrite | Level 9
Got it below is my code:
want=input(AESTDAT_RAW,anydtdte20.);
format want yymmdd10.;
Thanks!
heffo
Pyrite | Level 9
I'm always a bit careful with the anydate type of formats. It might still get it wrong and the default setting might be different when you run it from your own computer and if it is later ran on the server as a job.
Tom
Super User Tom
Super User

If the values really look like that then the DATE informat should work, just make sure to use a long enough width.

aestdat_date = input(aestdat_raw,date11.);
format aestdat_date yymmdd10.;

 

jskarda
Calcite | Level 5

We have a Table with a date in format MMM-19.  Example MAY-19.  Is there a way to generate a new sortable date column from this format?  Preferably 2019-05-31 in this example.  Any help would be much appreciated.

 

The last date in the month would be preferred.

heffo
Pyrite | Level 9

You should create your own thread instead, but here is an example that works if the date is an actual string and not just a formatted numeric value. If it is numeric to begin with, just use the intnx function. 

data want;
	date_s = "MAY-19";
	date_n = input(compress(date_s,"-"),monyy.);
	end_date_n = intnx ('month',date_n,0,'E');
	format date_n end_date_n yymmdd10.;
run;
jskarda
Calcite | Level 5
So if I wish to use this command, will this work? I tried and received an error.
I wish to use SL_FSCL_PERIOD to generate a new column named SL_FSCL_PERIOD_DT.

PROC SQL;
CREATE TABLE RXFFDM.ORCL_SL_JE_DTL_DT AS
SELECT *,
put(intnx ('month',SL_FSCL_PERIOD,0,'E')) format=yymmdd10. as SL_FSCL_PERIOD_DT
FROM RXFFDM.ORCL_SL_JE_DTL;
Quit;
heffo
Pyrite | Level 9

Hi,

Is that variable a string or a SAS numeric date? Do you want the variable to be a SAS date or a string? 

If it is a numeric, then you just have to change the format of that column to yymmdd10. 

If it is a string, then you have to use an input function to translate it to a SAS date. 

E.g.

data have;
	aestdat_raw = "28 feb 2019";
run;

data want;
	set have;
	aestdat_date = input (compress(aestdat_raw), date9.); *Use compress to remove the spaces, or you will get the year 2020!;
	format aestdat_date yymmdd10.;
run;
chinna0369
Pyrite | Level 9

Hi all, 

 

got it below is my code for my question:

want=input(AESTDAT_RAW,anydtdte20.);
format want yymmdd10.;

 

Thanks!

 

sas-innovate-white.png

Join us for our biggest event of the year!

Four days of inspiring keynotes, product reveals, hands-on learning opportunities, deep-dive demos, and peer-led breakouts. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 6485 views
  • 1 like
  • 4 in conversation