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

When I join Table1 and Table2 by Zipcodes, not all of zips in Table1 will be available in Table2.  Therefore E.G will show the not-matching zip codes as blank.

Table1Table2
ZipCodesZipCodes
MarketingZones

So any zips from Table2 does not match with Table1, I will get a blank cell under the column MarketingZones.  How do I rename the blank cell as "Other" or "Missing"?

See below for sample output.

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
CaseySmith
SAS Employee

One way to accomplish would be to create a SAS Format to format missing values with labels, then apply that format to the column.  For example...

  1. In EG, click Tasks->Data->Create Format to start the Create Format task (or you can just submit the code below, similar to what the task will generate)
  2. Give the format a name (ex. "MissingLabelFmt")
  3. Check Specify format width and give it a reasonable width (ex. 12)
  4. On the Define Formats page, click New
  5. Specify your desired label (ex. "Other" or "Missing")
  6. In the Range definition area, select Missing values in the Values dropdown
  7. Run the task

Note: By default, the Create Format task creates formats in the temporary WORK library.  If you want a permanent format, save to a permanent format catalog (specify in the task or code).

(The task will create code similar to the following, which you could just manually submit:

PROC FORMAT LIB=WORK;

  VALUE $MissingLabelFmt (DEFAULT=12)

  " " = "Other";

RUN;

)

After creating the user-defined format, apply it to your column...

  1. In the EG Query Builder (where you did the join), on the Select Data tab, double-click the MarketingZone variable
  2. Click the Change button next to the Format field
  3. Click the User Defined category and select the format you defined (ex. $MISSINGLABELFMT.)
  4. Click Ok, Ok, then Run

Result:

table.png

Note: Using a SAS format only affects how the values are displayed.  It does not alter the actual stored value (missing value in this case).


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

View solution in original post

3 REPLIES 3
CaseySmith
SAS Employee

One way to accomplish would be to create a SAS Format to format missing values with labels, then apply that format to the column.  For example...

  1. In EG, click Tasks->Data->Create Format to start the Create Format task (or you can just submit the code below, similar to what the task will generate)
  2. Give the format a name (ex. "MissingLabelFmt")
  3. Check Specify format width and give it a reasonable width (ex. 12)
  4. On the Define Formats page, click New
  5. Specify your desired label (ex. "Other" or "Missing")
  6. In the Range definition area, select Missing values in the Values dropdown
  7. Run the task

Note: By default, the Create Format task creates formats in the temporary WORK library.  If you want a permanent format, save to a permanent format catalog (specify in the task or code).

(The task will create code similar to the following, which you could just manually submit:

PROC FORMAT LIB=WORK;

  VALUE $MissingLabelFmt (DEFAULT=12)

  " " = "Other";

RUN;

)

After creating the user-defined format, apply it to your column...

  1. In the EG Query Builder (where you did the join), on the Select Data tab, double-click the MarketingZone variable
  2. Click the Change button next to the Format field
  3. Click the User Defined category and select the format you defined (ex. $MISSINGLABELFMT.)
  4. Click Ok, Ok, then Run

Result:

table.png

Note: Using a SAS format only affects how the values are displayed.  It does not alter the actual stored value (missing value in this case).


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

sdang
Quartz | Level 8

Thank you

sdang
Quartz | Level 8

You solved my problem.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 2260 views
  • 0 likes
  • 2 in conversation