BookmarkSubscribeRSS Feed
renjithr
Quartz | Level 8

Hi,

I have a requirement where I need to populate a field with year and month.

eg: 201201

Any suggestions?

4 REPLIES 4
Haikuo
Onyx | Level 15

'populate a field with year and month' from what??

Suppose that your source is date variable. Although you can concatenate all the way to your target, proc format seems to have an edge:

proc format;

picture my_yearmon

         low-high='%Y%0m'(datatype=date);

run;

data test;

format a date9.;

a=date();

b=put(a,my_yearmon6.);

run;

proc print;run;

Haikuo

renjithr
Quartz | Level 8

Thank you Hai.kuo!

Howles
Quartz | Level 8

The YYMMN6. format should do it.

Haikuo
Onyx | Level 15

Thanks for sharing! Yes, It does work! It is strange I can't find the doc, I could only locate it as informat, but not format from 9.2 online docs:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000363557.htm

Regards,

Haikuo

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 796 views
  • 0 likes
  • 3 in conversation