I am just starting out on my journey with SAS and am a bit confused about some SAS output.
I run this following code
DATA dates;
INPUT name$ bday date11.;
CARDS;
Sam 3 Jan 1960
George 12 Jul 1980
Lisa 14 feb 1975
Sean 14 feb 1975
;
RUN;
PROC PRINT DATA=dates;
FORMAT bday date9.;
RUN;
And notice that there is basically two outputs.
One output is the temporary data table. With this output, I am seeing the 'bday' column showing dates in a pure numeric format (SAS date format).
Whereas I also see the HTML output is displaying the 'bday' column with the dates as 03JAN1960 for example.
I am just curious, why there seems to be two different outputs?
In the PRINT step you have a FORMAT statement. That controls the appearance of the date variable and shows it as a date, with the Date9 format. If you put the format int he data set, which you can, then it does it automatically, note the changes below and check the output. FORMATS are used to control the appearance of a variable WITHOUT changing the underlying value.
DATA dates; INPUT name$ bday date11.; format bday yymmddd10.; CARDS; Sam 3 Jan 1960 George 12 Jul 1980 Lisa 14 feb 1975 Sean 14 feb 1975 ; RUN; PROC PRINT DATA=dates; *FORMAT bday date9.; RUN;
@rodneyc8063 wrote:
I am just starting out on my journey with SAS and am a bit confused about some SAS output.
I run this following code
DATA dates;
INPUT name$ bday date11.;
CARDS;
Sam 3 Jan 1960
George 12 Jul 1980
Lisa 14 feb 1975
Sean 14 feb 1975
;
RUN;PROC PRINT DATA=dates;
FORMAT bday date9.;
RUN;
And notice that there is basically two outputs.
One output is the temporary data table. With this output, I am seeing the 'bday' column showing dates in a pure numeric format (SAS date format).
Whereas I also see the HTML output is displaying the 'bday' column with the dates as 03JAN1960 for example.
I am just curious, why there seems to be two different outputs?
In the PRINT step you have a FORMAT statement. That controls the appearance of the date variable and shows it as a date, with the Date9 format. If you put the format int he data set, which you can, then it does it automatically, note the changes below and check the output. FORMATS are used to control the appearance of a variable WITHOUT changing the underlying value.
DATA dates; INPUT name$ bday date11.; format bday yymmddd10.; CARDS; Sam 3 Jan 1960 George 12 Jul 1980 Lisa 14 feb 1975 Sean 14 feb 1975 ; RUN; PROC PRINT DATA=dates; *FORMAT bday date9.; RUN;
@rodneyc8063 wrote:
I am just starting out on my journey with SAS and am a bit confused about some SAS output.
I run this following code
DATA dates;
INPUT name$ bday date11.;
CARDS;
Sam 3 Jan 1960
George 12 Jul 1980
Lisa 14 feb 1975
Sean 14 feb 1975
;
RUN;PROC PRINT DATA=dates;
FORMAT bday date9.;
RUN;
And notice that there is basically two outputs.
One output is the temporary data table. With this output, I am seeing the 'bday' column showing dates in a pure numeric format (SAS date format).
Whereas I also see the HTML output is displaying the 'bday' column with the dates as 03JAN1960 for example.
I am just curious, why there seems to be two different outputs?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.