SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
RandyStan
Fluorite | Level 6

Dear All:

I have two variables and I want to change the format and informat of these variable

VarA has 

Format BEST12. INFORMAT BEST32.

I want to change it to BEST12. and BEST12.

Var_B has $13. as the format and $13. as the INFORMAT

I want to change it to 

$12. as the format and $12. as the Informat

Can someone please help

Randy

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Once the variables are in a SAS data set, further changing of the informat is useless, it has no impact. So don't do that.

 

To change the format of a variable from $13. to $12. (why?)

 

proc datasets library=WORK; /* Or whatever the proper library name is */
    modify have; /* Or whatever the proper data set name is */
    format var_b $12.;
run;
quit;

    

You can also change the format in procedures where this variable is used. The only real impact of changing format from $13. to $12. is to chop off the last character, is that really what you want?

--
Paige Miller
russt_sas
SAS Employee

You can use PROC DATASETS to make your changes, for example:

 

data one;
x=100;
format x percent.;
run;

proc datasets lib=work nolist;
modify one;
format x best3.;
quit;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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