BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

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

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

robertrao
Quartz | Level 8

Thanks for the reply.

DISP=put(DischargeDispositionkey,dispkey2.);

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

Thanks

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

Astounding
PROC Star

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 598 views
  • 9 likes
  • 3 in conversation