BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5

DEFINE  BO_ZIP_CD    /  Display style(column)={tagattr="format:@" cellwidth=80pt just=center"BILLING ZIP";

The above code is being used in a program using ods tagset.  The output is an xml file.  If the zip code is something like 30011 then I am fine.  If the zip code is 300112222 I want to format the zipcode as 30111-2222.

If it is easier to address this in the dataset then let me know.  I believe there is a way to address in the ods output though.

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  I believe you will need to use CALL DEFINE in a COMPUTE block to specify a different format when you have a zip+4 versus just a zip code (based on the length of the data value).

cynthia


data testzip;
length name $12 zip_cd $9;
infile datalines;
input name $  zip_cd $;
return;
datalines;
alan 300112222
barb 202113333
carl 20022
dave 00221
edna 003334444
fran 777
;
run;

  
ods tagsets.excelxp file='c:\temp\zipcode.xml' style=sasweb;
 
proc report data=testzip nowd;
   column name zip_cd;
   define name / order;
   define zip_cd / display "Zip Code";
   compute zip_cd;
      lgzp = length(zip_cd);
      if lgzp = 9 then do;
        call define(_col_,'style',
                    'style={tagattr="format:00000\-0000" cellwidth=80pt just=center}');
      end;
      else if lgzp le 5 then do;
        call define(_col_,'style',
                    'style={tagattr="format:00000" cellwidth=80pt just=center}');
      end;
   endcomp;
  
run;
   
ods tagsets.excelxp close;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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