I formatted my numeric admission source (Admtsource) as shown below . My result does not show full description of admission source. How to I increase length of my label?
proc format library=fmts;
value ADMTSOURCE
00='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
01='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
02='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
run;
Thanks.
Bikash
Here is the log:
1 proc format;
2 value ADMTSOURCE
3 00='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
4 01='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
5 02='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
NOTE: Format ADMTSOURCE has been output.
6 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
7
8 data have;
9 format i admtsource.;
10 do i=0 to 3;
11 output;
12 end;
13 stop;
14 run;
NOTE: The data set WORK.HAVE has 4 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
15 proc print; run;
NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 4 observations read from the data set WORK.HAVE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.68 seconds
cpu time 0.59 seconds
CTorres
Hi,
It looks like you are using a numeric format but the values, 00, 01, and 02, are not numeric. The following code works and shows the entire text string.
proc format;
value $ ADMTSOURCE
'00'='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
'01'='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
'02'='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
run;
data test;
infile datalines;
input x $;
datalines;
00
01
02
;
proc print data=test;
format x $ADMTSOURCE.;
run;
Hope that helps,
M.
I do not know what you mean with "My result does not show full description of admission source". What are you trying to do?
The format works OK for me. See sample below:
proc format;
value ADMTSOURCE
00='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
01='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
02='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
run;
data have;
format i admtsource.;
do i=0 to 3;
output;
end;
stop;
run;
proc print; run;
CTorres
It would also be helpful for the community if you could copy the notes and/or error messages from your log to see if there is something we are missing.
Thanks,
M.
Here is the log:
1 proc format;
2 value ADMTSOURCE
3 00='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
4 01='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
5 02='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
NOTE: Format ADMTSOURCE has been output.
6 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
7
8 data have;
9 format i admtsource.;
10 do i=0 to 3;
11 output;
12 end;
13 stop;
14 run;
NOTE: The data set WORK.HAVE has 4 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
15 proc print; run;
NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 4 observations read from the data set WORK.HAVE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.68 seconds
cpu time 0.59 seconds
CTorres
Hi,
Sorry, I meant the original poster. I have come across quite a few of your solutions, CTorress; they are always interesting.
Also for the original poster, here is a link to a helpful (introductory) paper: http://www.lexjansen.com/pharmasug/2006/Tutorials/TU02.pdf
Thanks it worked in result. I saw my formatted value in library and thought it was not showing proper label. See label in library.
Result shows full labels.
Is there any way to increase length of label in library so that it can does not show truncated label?
You seem to be showing the output of the PROC FORMAT.
You can use CNTLOUT= option of PROC FORMAT to generate a dataset that will have the non truncated values for your labels.
Thanks. I will try it.
Try this:
proc format cntlout=want (keep= start end label)
maxlablen=80;
select ADMTSOURCE;
run;
title "FORMAT NAME: ADMTSOURCE";
proc print noobs; run;
CTorres
I am making format libraray, so where will your code fit in mine? Can you modify this code? fmts is my format library.
proc format library=fmts;
value ADMTSOURCE
00='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
01='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
02='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
run;
Just include the library= option in the proc format statement: proc format cntlout=want (keep= start end label) library=fmts
CTorres
proc format library=fmts;
value ADMTSOURCE(default=40)
00='TRANSFERRED FROM ON-SITE ACUTE CARE UNIT TO REHAB UNIT'
01='TRANSFERRED FOR ANOTHER HOSPITAL TO A SPECIALTY CENTER'
02='TRANSFERRED FROM ANOTHER HOSPITAL FOR ANY OTHER REASON';
run;
or try
format x ADMTSOURCE40. ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: