BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rodneyc8063
Fluorite | Level 6

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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? 


 

View solution in original post

2 REPLIES 2
Reeza
Super User

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? 


 

rodneyc8063
Fluorite | Level 6
Thanks very much for clarifying that!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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