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

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

1 ACCEPTED SOLUTION

Accepted Solutions
CTorres
Quartz | Level 8

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

View solution in original post

13 REPLIES 13
MaikH_Schutze
Quartz | Level 8

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.

CTorres
Quartz | Level 8

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;

print.png

CTorres

MaikH_Schutze
Quartz | Level 8

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.

CTorres
Quartz | Level 8

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

MaikH_Schutze
Quartz | Level 8

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

bikash
Calcite | Level 5

Thanks it worked in result. I saw my formatted value in library and thought it was not showing proper label. See label in library.

sas.png

bikash
Calcite | Level 5

Result shows full labels.

Is there any way to increase length of label in library so that it can does not show truncated label?

Tom
Super User Tom
Super User

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.

bikash
Calcite | Level 5

Thanks. I will try it.

CTorres
Quartz | Level 8

Try this:

proc format cntlout=want (keep= start end label)

            maxlablen=80;

  select ADMTSOURCE;

run;

title "FORMAT NAME: ADMTSOURCE";

proc print noobs; run;

CTorres

bikash
Calcite | Level 5

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;

CTorres
Quartz | Level 8

Just include the library= option in the proc format statement: proc format cntlout=want (keep= start end label) library=fmts

CTorres

Ksharp
Super User

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

sas-innovate-2024.png

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.

 

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
  • 13 replies
  • 1581 views
  • 6 likes
  • 5 in conversation