SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cdubs
Quartz | Level 8

 

The below was prefaced by 

 

%let startdate = '01JAN1999'd;
%let elig_2010 = '31DEC2010'd;
....

Question 1 of 2: For above, why is there a 'd' after the date? Is this how data is typically stored?

Question 2 of 2: For below, I think its saying when svcdate >= 01JAN1999 but svcdate <= 31DEC2010, then do the subsequent thing. But I don't understand what "then 1 else 0 end as test_2010" means. Does that mean make the variable test_2010 into 1 if true, else not? Why is there an "end"?

 

 

proc sql; 
	create table hbsag_lab (rename=(enrolid=patient_id)) as
	select distinct enrolid, svcdate,
	case when &startdate. <=svcdate <= &elig_2010. then 1 else 0 end as test_2010

from clean_dataset (where=(lab_test=1));

quit;
1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Your understanding is correct. As for the dates, quoting a date and then following it with a d converts the date to a SAS date, namely the number of days since January 1, 1960.

 

case statements, by definition, end with an end statement, followed by the variable name the selected/comuted values are assigned.

 

Art, CEO, AnalystFinder.com

 

View solution in original post

1 REPLY 1
art297
Opal | Level 21

Your understanding is correct. As for the dates, quoting a date and then following it with a d converts the date to a SAS date, namely the number of days since January 1, 1960.

 

case statements, by definition, end with an end statement, followed by the variable name the selected/comuted values are assigned.

 

Art, CEO, AnalystFinder.com

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 9098 views
  • 1 like
  • 2 in conversation