BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LRogers
Obsidian | Level 7

Hello,

What I am doing here is working however I'm curious if there is a better way...

1.  I have 12 different "PerioidLabelBuckets" that can all be formatted the same.  Currently, I have 12 format statements for each bucket (you can see in my attachment).  Is there a way to write one format statement that will take care of all the PeriodLabelBuckets?

2.  I ideally would like the date formatted as mon-yy (DEC-19).  Right now the format is monyy. so it shows DEC19.  There are examples of how to do this on the SAS community but I'm having a hard time getting understanding how it works and how to apply it to my program.  I'm using SAS Enterprise Guide 8.1.

Do i need a proc format statement with EG? 

The examples I've seen have proc format;

picture monyyd (default=6)

fmtA = '%b-%y' (datatype=date);

then a data _null_ statement....?

I'm new to SAS and hoping for a little guidance.  

thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  List processing can work for variables with similar names, as shown in #1 example. For #1, the FORMAT statement from the DATA step program is used. I have used a variable list in the FORMAT statement that starts with "date:" (the colon in the FORMAT statement means any variables that start with those 4 characters). Otherwise, you can specify multiple variables to share a format, as shown for #2, where date1 and date3 share the YYMMDD10 format and date2 and date4 share the WORDDATE format:

simplify_formats.png

 

You don't need 12 different format statements, although that is the brute force way to get the format used.

 

Hope this helps,

Cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
Diamond | Level 26

Hi:

  List processing can work for variables with similar names, as shown in #1 example. For #1, the FORMAT statement from the DATA step program is used. I have used a variable list in the FORMAT statement that starts with "date:" (the colon in the FORMAT statement means any variables that start with those 4 characters). Otherwise, you can specify multiple variables to share a format, as shown for #2, where date1 and date3 share the YYMMDD10 format and date2 and date4 share the WORDDATE format:

simplify_formats.png

 

You don't need 12 different format statements, although that is the brute force way to get the format used.

 

Hope this helps,

Cynthia