BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hi everyone. I am trying to onvert character date(MONYY) to DATE type yymmn6.

Here is my code:

data work.trans_load_re_oldfull;
set work.trans_load_re_oldfull;
    length newperiod $8.;
    charyear='JAN2018';
	newperiod=input(_NAME_,best.);

run;

 

Nothing came out. Anyone knows why?

3 REPLIES 3
imdickson
Quartz | Level 8

I have also tried putting format newperiod yymmn6. but the field is entirely blank.

PeterClemmensen
Tourmaline | Level 20

Do like this

 

data test;
   charyear='JAN2018';
   newperiod=input(charyear,monyy7.);
   format newperiod yymmn6.;
run;
Kurt_Bremser
Super User

First of all: do not overwrite a dataset in the same data step while you're still developing; any mistake will force you to recreate the dataset from its origins.

data work.trans_load_re_oldfull;
set work.trans_load_re_oldfull;
    length newperiod $8.;
    charyear='JAN2018';
	newperiod=input(_NAME_,best.);

run;

You are setting charyear, but don't use it.

You define newperiod as character, and then assign a numeric value to it, forcing an automatic type conversion. Bad.

Is _NAME_ present on your dataset? If yes, is it of type character? If yes, what does it contain?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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