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

Hi. So I am working on a hughe database on a secure server. why I can not copy-pasty codes into the browser.

anyways as I am working with health economics I need to multiply all results with a year factor. 

so for instance I made a variable totalmedicine I get a number and then if it comes from 2014 I have to multiply that number with 1.083 to get the equivalent amount in 2020. I have to do that for all years 2014-2019.

then I make a code

 

data allst3;

set all;

totalmedicin=eksp+tilpris;

if eksd >20131231 and eksd<20150101 then totalmedicin=totalmedicin*1.083;

run;

 

And so on for all the years and factors

when I run the code with or without the if then statement I get the same results in totalmedicin, what am I doing wrong?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Or

 

if year(eksd)=2014 then ...
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
if eksd >'31DEC2013'd and eksd<'01JAN2015'd then totalmedicin=totalmedicin*1.083;

The D after the quoted date indicates SAS should interpret this as an actual SAS date value. Of course, this assumes that EKSD is an actual SAS date value.

--
Paige Miller
yabwon
Onyx | Level 15

...or the "SAS way" 😉😉

if '31DEC2013'd < eksd < '01JAN2015'd then ...

B

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



PaigeMiller
Diamond | Level 26

Or

 

if year(eksd)=2014 then ...
--
Paige Miller

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 706 views
  • 1 like
  • 3 in conversation