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

Hi Kurt

Thanks for the solution, really appreciate that..

 

now i I am just trying to understand the code ,  is symputx function is used to convert the date in to character value ,  could you please 

elaborate the whole code step by step as I am not familiar with symputx,  put dims and the use input,  if you could help me understand this code then it will  be very beneficial for my learning. Please advise.

 

thanks

 

Tk

Kurt_Bremser
Super User

First of all, symputx is not a function, it is a call routine (in Pascal such a thing is called a procedure, the generic name in programming is subroutine; C does not have it, it is defined there as a function without a return value, eg void myproc();)

It does not return a value and always needs the call keyword.

Having said that, let's dissect one of the statements from outside in:

call symputx('startmonth',something_complicated_here);

The first parameter (or argument) to call symputx is the name of a macro variable to be created. The second parameter is the value that should go into this new macro variable. An optional third parameter would specifiy if the variable is to be created in the local ('l') or global ('g') symbol table.

Next layer:

put(some_number,best.)

Since call symputx (and call symput, BTW) want a character value as their second argument, I use the put() function to prevent any automatic conversion (I like to have complete control over what the computer does for me). The additional leading blanks from the best. format are being taken care of by call symputx.

Next layer:

dhms(input("&start.-01",yymmdd10.),0,0,0)

The dhms() function computes a datetime value from 4 parameters: date, hours, minutes, seconds. The date needs to be a valid SAS date value (number of days calculated from 1960-01-01, back in time to 1582, and forward to 19999, but limited by the four digits for years in most date formats)

Innermost layer:

input("&start.-01",yymmdd10.)

Make a yyyy-mm-dd string from your macro variable, and use the proper informat to convert the string to a SAS date value.

 

bondtk
Quartz | Level 8
Fantastic, I think I learn a new thing today, really appreciate your time,
Just one question , when you added 0,0,0 after the format , are these for h, m and seconds.


Thanks

Tk
Astounding
PROC Star

It may not be relevant, since you already have a solution.  But here is the point I was trying to make.  Perhaps this will help you frame questions in the future.

 

Here's what you started asking for:

 

where d_entry >= '2016-11-01 00:00:00.000' and d_entry <  '2017-10-01 00:00:00.000' ;

 

Here's what you actually needed (using a different date range, but that's not the point here):

 

where d_entry >= "01JUN2017:00:00:00.000"dt and d_entry < "01SEP2017:00:00:00.000"dt ;

 

You need to realize that these statements are different, and the solution will vary depending on what you actually need.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 19 replies
  • 2395 views
  • 5 likes
  • 3 in conversation