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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.