BookmarkSubscribeRSS Feed
srdhoble
Calcite | Level 5

Hi Team,

              I am trying to convert SAS code to SQL.

first step is to get precode converted properly.

Need help in converting below code to SQL.I think we will need to have global parameters in SQL code.Corect me if i am wrong.

 

Here is the sas code:

%LET RUNOUT = 0;
%LET PERIODS = 4;
%let ENRLMNTDY = 15;
%LET RUN_DATE = %SYSFUNC(TODAY());
%LET START_DATE = %SYSFUNC(INTNX(MONTH, &RUN_DATE.,%EVAL(-12*&PERIODS.-&RUNOUT.),B));
%LET END_DATE = %SYSFUNC(INTNX(MONTH, &RUN_DATE.,%EVAL(-1-&RUNOUT.),E));

 

3 REPLIES 3
Reeza
Super User

It depends on how it's used in the code. If there are no loops but just filters then you may not need them, but otherwise you may. 

 

Edit: Remember that its better if you don't do a line to line conversion for code, determine the purpose and figure out how to replicate this in SQL. I'm assuming you're not using SAS SQL but MS SQL or Oracle SQL? 

 

anoopmohandas7
Quartz | Level 8

Are you expecting the below variables to be a part of a dataset when read through SQL or something else ?

LinusH
Tourmaline | Level 20

Why are you doing this?

If you are in a migration from SAS, don't expect too much help here. Hire the muscle instead to do this for you.

Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 881 views
  • 0 likes
  • 4 in conversation