BookmarkSubscribeRSS Feed
Ps8813
Fluorite | Level 6
For character variable if i use length statement , it will change format and informat as well.

In numeric variable if ii only use format statement, it will change informat also. But if i only use informat statement it wont change the format.
4 REPLIES 4
Reeza
Super User

The informat and format don't have to match.

 

I'm also not clear on what your trying to ask, can you please clarify your question?

Steelers_In_DC
Barite | Level 11

You use informat to tell SAS how to read input, it has nothing to do with the display.  Format is how SAS will display your data and has nothing to do with how SAS reads the data from the source.

Ps8813
Fluorite | Level 6

Data test1;

length x $32 ;

format y 4.;

informat z 4.;

run;

 

In above case , we have 3 variables x ,y, z. 

After running the code we will get the below attributes of variables:-

X:- length $32

     informat $32.

     format $32.

y:- length 8

     informat 4.

     format 4.

z:- length 8

     informat 4.

     format best12.

 

If u will check Y and Z variable. U can see that for 'Y' format statement has changed informat as well.

But for 'Z' variable informat statement has not changed format.

SO my question is why SAS is doing so?

 

 

Kurt_Bremser
Super User

I can't tell you why SAS is doing it, I can only tell you that SAS has (probably) been doing it this way for a long time. Just keep in mind that it does, and write your code accordingly.

 

Anytime I need a specific format or informat assigned to a variable, I always write it out explicitly; I never let a computer assume something that could bite me in the ass later.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5550 views
  • 0 likes
  • 4 in conversation