Desktop productivity for business analysts and programmers

Extracting Monthname and Monthnumber from a date in IMS Expression Editor

Reply
N/A
Posts: 0

Extracting Monthname and Monthnumber from a date in IMS Expression Editor

Hi,

I have an Orderdate column with datetime as its datatype. I have to create three data items Orderyear, Ordermonthname and Ordermonthnumber in the SAS Information Map Studio.

Eg.
Orderdate : 01JUL2001:00:00:00

Orderyear : 2001
Ordermonthname : July
Ordermonthnumber : 07

I have created the Orderyear data item by configuring the format to DTYEAR under the Classification/Formats pane. It is working for me. I don’t know what format I have to specify for the data items Ordermonthname and Ordermonthnumber.

Kindly guide me to get my desired result.

Regards,
Sujeev
Regular Contributor
Posts: 187

Re: Extracting Monthname and Monthnumber from a date in IMS Expression Editor

Try using functions instead:

data _null_;
a= "01JUL2001:00:00:00"dt ;
b = year(datepart(a));
c = put(month(datepart(a)),z2.);
d = put(day(datepart(a)),z2.);
put b= c= d=;
run;
N/A
Posts: 0

Re: Extracting Monthname and Monthnumber from a date in IMS Expression Editor

Hi FredrikE,

Thanks for your response.

I still don't understand how i have to use this query inside the SAS Information Map Studio. I have given an example with Orderdate as mentioned in my previous post.

Actually, i have observation from the year 2001 to 2004. I have derived the columns Ordermonthnumber and Ordermonthname from the Orderdate column in the SAS Information Map Studio. If am using the query as mention by you, how i will pass the values for rest of the observations to the variable 'a'. I will use those columns in the SAS Web Report Studio to create reports.

Sorry, i am new to the SAS. Correct me if am wrong and kindly guide me.

Regards,
Sujeev
Super Contributor
Super Contributor
Posts: 3,174

Re: Extracting Monthname and Monthnumber from a date in IMS Expression Editor

The code snippet provided in the reply is just an example of how to use a DATETIME variable to derive the other informational values you required, all based on the OrderDate. If you need to use additional data strings with year and/or month_name, you can derive these new variables with an expression that uses the correct SAS function, as was demonstrated in the previous reply.

The SAS-hosted documentation at the SAS support http://support.sas.com/ website is available and you can search the site using the website SEARCH facility or using something like the Google advanced search argument below:

enterprise guide using sas functions site:sas.com

With this search, you will find SAS-hosted documentation and also supplemental technical and conference topic-related reference material.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Extracting Monthname and Monthnumber from a date in IMS Expression Editor

Hi Scott Barry,

Thanks for your guidance. I'll check and let you know.

Regards,
Sujeev
Ask a Question
Discussion stats
  • 4 replies
  • 127 views
  • 0 likes
  • 3 in conversation