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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1284 views
  • 2 likes
  • 6 in conversation