BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

data ex1 ;
date='09sep2018'd ;
output ;
date='10sep2018'd ;
output ;
date='11sep2018'd ;
output ;
date='12sep2018'd ;
output ;
format date date9. ;
run;

 

i want to keep first two records in date9. formats and remaining records keep in yymmdd10. format see onnce my program

if any mistakes please let me know
proc format ;
value jj low-'10sep2018'd=[ddmmyyd10.] ;
'11sep2018'd-high=[date9.] ;
run;
data ex2 ;
set ex1 ;
new=date ;
format new jj. ;
run;

 

finaly data comes like see below dataset

date

new

09SEP2018

09-09-2018

10SEP2018

10-09-2018

11SEP2018

21438

12SEP2018

21439

3 REPLIES 3
Reeza
Super User

Read your log.

 


@thanikondharish wrote:

data ex1 ;
date='09sep2018'd ;
output ;
date='10sep2018'd ;
output ;
date='11sep2018'd ;
output ;
date='12sep2018'd ;
output ;
format date date9. ;
run;

 

i want to keep first two records in date9. formats and remaining records keep in yymmdd10. format see onnce my program

if any mistakes please let me know
proc format ;
value jj low-'10sep2018'd=[ddmmyyd10.] ;
'11sep2018'd-high=[date9.] ;
run;
data ex2 ;
set ex1 ;
new=date ;
format new jj. ;
run;

 

finaly data comes like see below dataset

date

new

09SEP2018

09-09-2018

10SEP2018

10-09-2018

11SEP2018

21438

12SEP2018

21439


 

Astounding
PROC Star

To paraphrase an old saying, "Those who refuse to read have no advantage of those who cannot read."

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Maxim 2:

https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers...

 

After a tidy up (and using the Code window which is the {i} above post area):

data ex1;
  date='09sep2018'd;
  output;
  date='10sep2018'd;
  output;
  date='11sep2018'd;
  output;
  date='12sep2018'd;
  output;
  format date date9.;
run;
proc format;
  value jj 
    low-'10sep2018'd=[ddmmyyd10.]
    '11sep2018'd-high=[date9.];
run;
data ex2;
  set ex1;
  new=date;
  format new jj.;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 3 replies
  • 1386 views
  • 0 likes
  • 4 in conversation