Formats

Reply
Super Contributor
Posts: 1,040

Formats

Hi,

I have asked similar question regarding formats earlier..

How can I create a charecter variable DISP shown below with a specific length for example length=2

DISP=put(DischargeDispositionkey,dispkey.);

Thanks

Esteemed Advisor
Esteemed Advisor
Posts: 7,189

Re: Formats

By using the length statement:

length DISP $2;

Not entirely sure what your question is, perhaps provide test data in the form of a datastep and required output.

Super Contributor
Posts: 1,040

Re: Formats

Thanks for the reply.

DISP=put(DischargeDispositionkey,dispkey2.);

cant I use like this while the format is being applied itself???

Thanks

Esteemed Advisor
Esteemed Advisor
Posts: 7,189

Re: Formats

I can't remember from top of my head (I avoid using formats), this is a user format yes?  You can try it, but I believe the format itself is just a display thing and length doesn't affect user formats.  You could of course do:

DSIP=substr(put(DischargeDispositionkey,dispkey.),1,2);

Respected Advisor
Posts: 4,951

Re: Formats

You absolutely can do this.  That's the reason that is illegal to name a user-defined format ending with a number.  It gives you the flexibility to add the width later, when using the format.

Ask a Question
Discussion stats
  • 4 replies
  • 182 views
  • 9 likes
  • 3 in conversation