BookmarkSubscribeRSS Feed
piplani81
Calcite | Level 5

Hello All,

 

I am not able to create user define format can you pls check below 2 code and let me know where i am doing mistake.

 

Proc format;
value typefmt
'PA'='Passenger'
'CA'='Car';
run;

Proc print Data =S.Car;
Format Vehicle_type $typefmt.;
run;

 

 

and 

 

 

Proc format;
Value Newgrp low-175='<175'
175-<200='175-200'
200-High= '>200';
run;
proc Freq data =S.Car;
Format Length Newgrp.;
Table Length;
run;

 

 

 

 

 

7 REPLIES 7
error_prone
Barite | Level 11
If you want to create a char-format, the name must begin with $.
I can't say anything about the second problem, because you failed to explain what the problem is.
piplani81
Calcite | Level 5

I have a car sales data set in which one variable is Vehicle_type ( Passenger and Car) i would like to show  

'PA'='Passenger'
'CA'='Car'

but after run the following code neither i am getting any error nor format created. Pls help.

 

Proc format;
value $typefmt
'PA'='Passenger'
'CA'='Car';
run;

Proc print Data =S.Car;
Format Vehicle_type $typefmt.;
run;

 

 

gamotte
Rhodochrosite | Level 12

Works for me :

 

libname S "c:\temp";

data S.car;
input Vehicle_type $;
cards;
PA
CA
;
run;

Proc format;
value $typefmt
'PA'='Passenger'
'CA'='Car';
run;

Proc print Data =S.Car;
Format Vehicle_type $typefmt.;
run;

What does the log indicate ?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

What error, post the log part.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please formulate the question which exact descriptions of hat the issue is, what logs say, test data/required output etc.  In the first instance typefmt is missing a $, in the second?

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000063536.htm

ballardw
Super User
Proc format;
Value Newgrp 
low-175='<175'
175-<200='175-200'
200-High= '>200';
run;

has an issue with 175 being in two groups (and not a multilabel format). From your label text I suspect that you might actually want:

 

Proc format;
Value Newgrp 
low -< 175='<175'
175 -< 200='175-200'
200 -   High= '>200';
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1340 views
  • 2 likes
  • 6 in conversation