BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

Hi,

I have used proc format in the past and have a wired question...

I want to know what happens if I don't put the other in the proc format?????

as u can see I used "other" in $origin and not in the $origin...............and I am using those two formats on the same variable

automatically doesn't it get set to missing? do we have to use OTHER????

Thanks

value $orign

/*'EO','RA','1'='1'*/

/*'OP','OS','2'='2'*/

'TH','4'='4'

/*'NB','NP','NS',*/'TE','TI',/*'25',*/'5','24'='5'

/*'NE',*/'RB','TB','TF','TP','TR','TS','TT','TU','TV','TW','6','18'/*,'26'*/='6'

other=" "

;

value $orignB

'25', 'NS', 'NP', 'NB'='5'

'NE', '26'='6'

;

NB04=put(Code,$orign.);

if TYPE=4 then NB04=put(Code,$orignB.);

7 REPLIES 7
ballardw
Super User

Generally if you do not use an OTHER assignment then the original value will be displayed. If numeric that may be in a BEST type format. I think if your format is character and you assign a default length shorter than "other" values they could be truncated to the length of the setting in the format.

robertrao
Quartz | Level 8

Hi Ballard,

Thanks for the reply

If I have properly understood you then:

In my example above" if I did not use "Other "u meant : what ever is the CODE value will be put into NB04.....even if I didn't say so????????

CODE

24

25

26

27

28

29

value $orign

'24', '25','26'='4'

'27'='5'

;

run;

NB04=put(Code,$orign.);

NB04 has a value of 28 and 29 where CODE is 28 and 29?????

Thanks

art297
Opal | Level 21

As long as you use a format of $orign2.  Otherwise I think they will appear as 2 and 2 rather than 28 and 29.

robertrao
Quartz | Level 8

Hi Art,

Thanks for the reply.

I did not clearly understand. Could you show an example so that I would better understand???

Thanks

art297
Opal | Level 21

proc format;

value $orign

'24', '25','26'='4'

'27'='5'

;

run;

data have;

  input CODE $;

  format code $orign2.;

  cards;

24

25

26

27

28

29

;

robertrao
Quartz | Level 8

I was thinking so far  if I am creating a new variable(UBO4) like shown below and then put the resultant in that variable after applying the format........

28 and 29 would not come there into the UBO4 column.....even if you give a length of how much ever to the format.

I was thinking there would be a blank in UBO4 column corresponding to the 28 and 29 in the ID column!!!!!!!!since we did not assign anything to it........it seems clearly that is bringing the ID values (original values) for which ever format doesn't get applied????

But it seems clearly that it is wrong!!!!

proc format;

value $orign

'24', '25','26'='AA'

'27'='BB'

;

run;

data have;

  input CODE $;

  cards;

24

25

26

27

28

29

;

data want;
set have;
UBO4=put(Code,$orign.);
run;

ballardw
Super User

That's exactly the behavior I mentioned earlier: if you don't have an "other" then the original value is the result of the format. If you want a blank then use an other= ' ' statement in your format.

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 740 views
  • 0 likes
  • 3 in conversation