Help using Base SAS procedures

Increase length during format

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Increase length during format

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


Accepted Solutions
Solution
‎01-07-2015 01:37 PM
Regular Contributor
Posts: 180

Re: Increase length during format

Posted in reply to MaikH_Schutze

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


All Replies
Contributor
Posts: 45

Re: Increase length during format

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.

Regular Contributor
Posts: 180

Re: Increase length during format

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

Contributor
Posts: 45

Re: Increase length during format

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.

Solution
‎01-07-2015 01:37 PM
Regular Contributor
Posts: 180

Re: Increase length during format

Posted in reply to MaikH_Schutze

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

Contributor
Posts: 45

Re: Increase length during format

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

Contributor
Posts: 21

Re: Increase length during format

Posted in reply to MaikH_Schutze

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

Contributor
Posts: 21

Re: Increase length during format

Result shows full labels.

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

Super User
Super User
Posts: 7,039

Re: Increase length during format

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.

Contributor
Posts: 21

Re: Increase length during format

Thanks. I will try it.

Regular Contributor
Posts: 180

Re: Increase length during format

Try this:

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

            maxlablen=80;

  select ADMTSOURCE;

run;

title "FORMAT NAME: ADMTSOURCE";

proc print noobs; run;

CTorres

Contributor
Posts: 21

Re: Increase length during format

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;

Regular Contributor
Posts: 180

Re: Increase length during format

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

CTorres

Super User
Posts: 10,023

Re: Increase length during format

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 13 replies
  • 434 views
  • 6 likes
  • 5 in conversation