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.
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
SAS Super FREQ

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
SAS Super FREQ

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

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1 reply
  • 3465 views
  • 2 likes
  • 2 in conversation