Help using Base SAS procedures

what happens when format is different from informat

Reply
Contributor
Posts: 74

what happens when format is different from informat

Hi,

I have a new patient dataset where patient num(numeric field) is in format 11 and informat 11
but recently the team who provides the patient dataset created new patient dataset and the patient num is in format 2O AND informat 20.

but when i create another version of new patient dataset i want to use patient num in format 11 and informat 11.
i use sql to create another version of new patient dataset,and i use like this
proc sql;
create table newver as select patnum format 11. from newpat ;
quit;

My question is what if i do not change the informat here?
Can any one help?
Super Contributor
Super Contributor
Posts: 3,174

Re: what happens when format is different from informat

The associated INFORMAT is only used when no INFORMAT is named on an INPUT statement. You will need to review the SAS program that loads your input data for a specified or implied INFORMAT definition. DOC link provided below for INFORMAT statement:

http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000178244.htm


Scott Barry
SBBWorks, Inc.
Super Contributor
Posts: 359

Re: what happens when format is different from informat

The format and informat is not a problem. What I would worry about given your statement is the length of the variable. Make sure you are not truncating the new data to fit it into 11.
Super Contributor
Super Contributor
Posts: 3,174

Re: what happens when format is different from informat

Though not mentioned by the OP, a declared LENGTH attribute (ATTRIB or LENGTH statement) "may" affect the SAS NUMERIC variable resolution in a subsequent DATA/PROC step, if the SAS variable is kept.

However, most definitely if an INFORMAT is used on an INPUT statement, there also may be incorrect data interpretation.

Scott Barry
SBBWorks, Inc.


33 data x;
34 length a 4;
35 format a 14.4;
36 input a ;
37 putlog _all_;
38 cards;

a=22212.2222 _ERROR_=0 _N_=1
NOTE: The data set WORK.X has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds


40 run;
41 data _null_;
42 set ;
43 putlog _all_;
44 run;

a=22212.2188 _ERROR_=0 _N_=1
NOTE: There were 1 observations read from the data set WORK.X.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds Message was edited by: sbb
Ask a Question
Discussion stats
  • 3 replies
  • 319 views
  • 0 likes
  • 3 in conversation