BookmarkSubscribeRSS Feed
anandmgjsa
Fluorite | Level 6

hi,

 

data report_week_oct_dec_data;

set report_04_01_2021(In = in1)

set report_11_01_2021(In = in2) 

set report_18_01_2021(rename = (date = chardate))

set report_25_01_2021(rename = (date = chardate))

set report_28_12_2020(rename = (date = chardate));

if not missing (chardate) then date = input(chardate,yymmdd10.);

if in1 or in2 then date = input(put(date,f8.),yymmdd10.);

format date yymmdd10.;

run;

 

After running this code, the date column is coming blank.

Please help.

5 REPLIES 5
ballardw
Super User

So, what did the log say?

Type it if needed.

 

We cannot diagnose things without information.

 

Strongly suspect you still aren't providing the details of the variable "date" correctly as it appears in your multiple data sets.

Have you run Proc Contents on all those sets?

What type and format are currently assigned to your Date variable in each one?

 

anandmgjsa
Fluorite | Level 6

the datatype of date in the 1st two data sets it is best32. and in the last 3 datasets it char10.

ballardw
Super User

@anandmgjsa wrote:

the datatype of date in the 1st two data sets it is best32. and in the last 3 datasets it char10.


And the LOG when you ran that data step? Or rerun and an type out  any of the messages generated.

From the "code" you posted I would expect to see multiple errors of data set "set" not found.

data report_week_oct_dec_data;

set report_04_01_2021(In = in1)
set report_11_01_2021(In = in2) 
set report_18_01_2021(rename = (date = chardate))
set report_25_01_2021(rename = (date = chardate))
set report_28_12_2020(rename = (date = chardate));
if not missing (chardate) then date = input(chardate,yymmdd10.);
if in1 or in2 then date = input(put(date,f8.),yymmdd10.);
format date yymmdd10.;
run;

Those "set" I have highlighted above would be used as data set names.

 

When I create two very small data sets with different "date" type values:

data junk1;
   date = '20200418';
run;
data junk2;
   date= 20210515;
run;

And then run a data step like your code shows:

366  data report_week_oct_dec_data;
367  set junk2(In = in1)
368  set junk1(rename = (date = chardate));
ERROR: File WORK.SET.DATA does not exist.
369  if not missing (chardate) then date = input(chardate,yymmdd10.);
370  if in1 then date = input(put(date,f8.),yymmdd10.);
371  format date yymmdd10.;
372  run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.REPORT_WEEK_OCT_DEC_DATA may be incomplete.  When this step was
         stopped there were 0 observations and 2 variables.
WARNING: Data set WORK.REPORT_WEEK_OCT_DEC_DATA was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

I have a version of the data set from testing other code, so any values in the report_week_oct data set are from a previous run because the multiple SET in your code is an ERROR.

However:

374  data report_week_oct_dec_data;
375  set junk2(In = in1)
376      junk1(rename = (date = chardate));
377  if not missing (chardate) then date = input(chardate,yymmdd10.);
378  if in1  then date = input(put(date,f8.),yymmdd10.);
379  format date yymmdd10.;
380  run;

NOTE: There were 1 observations read from the data set WORK.JUNK2.
NOTE: There were 1 observations read from the data set WORK.JUNK1.
NOTE: The data set WORK.REPORT_WEEK_OCT_DEC_DATA has 2 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Runs just fine, date is indeed a date value formatted as yymmdd10 for both records.

 

 

AMSAS
SAS Super FREQ

All this appears to be a follow up to the original post for awareness and history.

@anandmgjsa I have a more general question, why are the datasets report_* in different formats (i.e. the first 2 datasets date is numeric, the remaining date is character). Given the dataset names appear to be consistent, I'd expect the datasets to have the same variables and all variables be the same type. 
I would strongly suggest you look at the code that generates these datasets and make the datasets consistent. 

PaigeMiller
Diamond | Level 26

@anandmgjsa 

When you have a problem where code is not doing what you think it should be doing, SHOW US the log. There are NOTEs and WARNINGs and ERRORs in the log that will help diagnose the problem.

 

You need to show us the entire log of this DATA step. Do not pick parts of the log of this DATA step to show us, and not show us other parts; do show us the whole log of this DATA step, 100%, every single character. Copy the log as text and paste it into the window that appears when you click on the </> icon. (And for the future, you will get better and quicker answers if you follow this advice every single time your code isn't working)

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 678 views
  • 1 like
  • 4 in conversation