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.
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;
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.
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.