When I run this code, SAS is automatically assigning formats and informats to all of my data when I only want a format on my date variable. Am I accidentally creating these formats and informats or I am missing something? Is there any way that I can get SAS to stop creating these Formats and Informats? I have copied the formats that I keep getting below.
* Creating data for Iowa *;
DATA WORK.Vitals_IA ;
HtIn = HtCm * 2.54;
WtLb = WtKg * .454;
DROP HtCm WtKg;
SET HypImpt.Vit_IA (RENAME = (SSN = FedData));
SSN = PUT(FedData, 11.);
DROP FedData;
RUN;
* Creating data for Mississippi *;
DATA WORK.Vitals_MS (RENAME = (VisitDate = VisitDt Height = HtIn Weight = WtLb));
SET HypImpt.Mississippi_VS;
RUN;
* Creating data for Utah *;
DATA WORK.Vitals_UT;
LENGTH SSN $11.
pt1 $3.
pt2 $2.
pt3 $4.;
SET HypImpt.utah_vitals: (RENAME = (ApptDate = VisitDt));
IDs = STRIP(SSN);
pt1 = substr(IDs,1,3);
pt2 = substr(IDs,4,2);
pt3 = substr(IDs,6,4);
SSN = CATX('-', pt1, pt2, pt3);
RUN;
PROC TRANSPOSE
DATA = WORK.Vitals_UT
OUT = WORK.Vitals_UT2 (DROP = _NAME_ _LABEL_ RENAME = (Col1 = HtIn Col2 = WtLb Col3 = SBP Col4 = DBP));
VAR Value;
BY VisitDt SSN;
RUN;
* Creating Combined Data Set *;
DATA HypTabs.Vitals (LABEL = Vital Signs);
ATTRIB SSN LABEL= 'Social Security Number' LENGTH = $11.
VisitDt LABEL= 'Visit Date' LENGTH = 8. FORMAT = DATE9.
HtIn LABEL = 'Height (In)' LENGTH = 8.
WtLb LABEL= 'Weight (Lb)' LENGTH = 8.
SBP LABEL= 'Systolic BP (mmHg)' LENGTH = 8.
DBP LABEL= 'Diastolic BP (mmHg)' LENGTH = 8.;
KEEP SSN VisitDt HtIn WtLb SBP DBP;
SET WORK.Vitals_IA
WORK.Vitals_MS
WORK.Vitals_UT2;
RUN;
PROC SORT DATA= HypTabs.Vitals;
BY SSN VisitDt;
RUN;
PROC CONTENTS DATA= HypTabs.Vitals VARNUM;
RUN;
PROC PRINT DATA= HypTabs.Vitals (obs=1);
RUN;
Variables in Creation Order# Variable Type Len Format Informat Label123456
SSN | Char | 11 | $9. | $9. | Social Security Number |
VisitDt | Num | 8 | DATE9. | Visit Date | |
HtIn | Num | 8 | BEST. | Height (In) | |
WtLb | Num | 8 | BEST. | Weight (Lb) | |
SBP | Num | 8 | BEST12. | Systolic BP (mmHg) | |
DBP | Num | 8 | BEST12. | Diastolic BP (mmHg) |
That is the step where you are reading in an unknown number of inputs because you are using the colon wildcard in the list of dataset on the SET statement. So you need to check all of them to see whether any of them have a format attached to the variables you are interested in. When you combine multiple datasets SAS will pick the first non missing format for each variable. So you just cannot check the first dataset because if the variable has no format attached in the first dataset, but does in the second dataset then the result will be to use the format that the variable had in the second dataset.
To remove the formats just add a format statement that lists variable, but has no format specification, to your data step.
format visitdt date9. ssn HtIn WtLb SBP DBP ;
What formats are attached to those variables in the source datasets?
HypImpt.Vit_IA
HypImpt.Mississippi_VS
HypImpt.utah_vitals:
None. Before I start manipulating anything, there are no formats or informats attached to the data.
That is the step where you are reading in an unknown number of inputs because you are using the colon wildcard in the list of dataset on the SET statement. So you need to check all of them to see whether any of them have a format attached to the variables you are interested in. When you combine multiple datasets SAS will pick the first non missing format for each variable. So you just cannot check the first dataset because if the variable has no format attached in the first dataset, but does in the second dataset then the result will be to use the format that the variable had in the second dataset.
To remove the formats just add a format statement that lists variable, but has no format specification, to your data step.
format visitdt date9. ssn HtIn WtLb SBP DBP ;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.