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

Hello all,

          i am going to read a file name thats like B11_20110926_DeliverStatus.csv

          i am able to collect the date by substring the file using the following code:

%substr(B11_20110926_DeliverStatus.csv,4,8);

          but i am unable to get the MONTH of the substring's file.

          is that possible to convert the 20110926 to a sas datetime format?

          i try to get the date by using following code.

          is that still anyway to do so?

Regards:

Liangck

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Isn't %substr(B11_20110926_DeliverStatus.csv,9,2); working for you?

You can use the macro function %sysfunc, whic let's you use (almost) any SAS function within a macro context:

%let sasdate = %sysfunc(inputn(%substr(B11_20110926_DeliverStatus.csv,5,8),yymmdd8.));

/Linus

Data never sleeps

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20

Isn't %substr(B11_20110926_DeliverStatus.csv,9,2); working for you?

You can use the macro function %sysfunc, whic let's you use (almost) any SAS function within a macro context:

%let sasdate = %sysfunc(inputn(%substr(B11_20110926_DeliverStatus.csv,5,8),yymmdd8.));

/Linus

Data never sleeps
RD2
Fluorite | Level 6 RD2
Fluorite | Level 6

%let sdate=20061212;

%let ndate=%sysfunc(inputn(&sdate,yymmdd10.));

%let nmonth=%sysfunc(month(&ndate));

%put _user_;

Liangck
Calcite | Level 5

Linus Randy Dai:

          Thank you both, i tried both answer and i got got the result perfectly.

          thanks, apperciate alot.

Regards

Liangck

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5777 views
  • 3 likes
  • 3 in conversation