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

Hello all.I want to use qtr function but the date d that is shown in result is 01/01/1960 which is different from the date that i want as i put in my sas code.Any help is appreciated to correct my mistake.

 

data nn;
d = '05/19/2016' ;
p     = qtr   (d);
format  d  ddmmyy10. ;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

SAS date values need to be specified in DATE9 format which is ddMONYY such as 16May2016

And when specifying a date, you need to include a d after the quotation marks to indicate the difference between a date and just a plain string. 

 

Note that you can also just format your date as a quarter variable, I created a variable Z, which is identical to d but formatted as a quarter.

 

data nn;
d = "19May2016"d;
p     = qtr   (d);

z = d;
format  d  ddmmyy10.  z qtr.;
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
data nn;
   d='19may2016'd;
   p=qtr(d);
   format d ddmmyy10.;
run;

 QTR function requires a numeric variable, and in your code d is a character variable. Specify it as a date constant using the date9 format as "19may2016"d with the trailing d specifying that it is a date constant.

Reeza
Super User

SAS date values need to be specified in DATE9 format which is ddMONYY such as 16May2016

And when specifying a date, you need to include a d after the quotation marks to indicate the difference between a date and just a plain string. 

 

Note that you can also just format your date as a quarter variable, I created a variable Z, which is identical to d but formatted as a quarter.

 

data nn;
d = "19May2016"d;
p     = qtr   (d);

z = d;
format  d  ddmmyy10.  z qtr.;
run;

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 16. 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
  • 3 replies
  • 1071 views
  • 1 like
  • 4 in conversation