Hi.….when I run the attached code for 200 records it seems to work fine but when I re-run it for 500 records it doesn't run. Any suggestions why this might be occurring. Thanks.
data wan (drop = _:) ;
set wan2 ;
_minym = input (put (start_yrmo, 6.), yymmn6.) ;
do _n_ = 1 by 1 until (_minym = input(put(end_yrmo,6.),yymmn6.)) ;
output ;
_minym = intnx ("mon", _minym, 1) ;
start_yrmo = input(put (_minym, yymmn6.),6.);
end ;
run ;
Log Outputs:
64
65 data wan (drop = _:) ;
66 set wan2(obs=200) ;
67 _minym = input (put (start_yrmo, 6.), yymmn6.) ;
68 do _n_ = 1 by 1 until (_minym = input(put(end_yrmo,6.),yymmn6.)) ;
69 output ;
70 _minym = intnx ("mon", _minym, 1) ;
71 start_yrmo = input(put (_minym, yymmn6.),6.);
72 end ;
73 run ;
NOTE: There were 200 observations read from the data set WORK.WAN2.
NOTE: The data set WORK.WAN has 901 observations and 10 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
64
65 data wan (drop = _:) ;
66 set wan2(obs=1000) ;
67 _minym = input (put (start_yrmo, 6.), yymmn6.) ;
68 do _n_ = 1 by 1 until (_minym = input(put(end_yrmo,6.),yymmn6.)) ;
69 output ;
70 _minym = intnx ("mon", _minym, 1) ;
71 start_yrmo = input(put (_minym, yymmn6.),6.);
72 end ;
73 run ;
NOTE: Invalid argument to function INPUT at line 71 column 19.
NOTE: The DATA step has been abnormally terminated.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
2290719 at 70:15
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 70:15 120012 at 71:19
NOTE: There were 459 observations read from the data set WORK.WAN2.
This is a case where you need to look at the data set and see what is in there. Somewhere after row 200, most likely on row 459, you have a value of _minym that cannot be written using informat yymmn6.
This is a case where you need to look at the data set and see what is in there. Somewhere after row 200, most likely on row 459, you have a value of _minym that cannot be written using informat yymmn6.
Hi Paige...thanks for your help.....the issue was that it is possible to have the same start_yrmo and end_yrmo and it didn't know how to handle it.....Thanks
Without knowing teh data this is difficult to pinpoint. But some general remarks are:
I advise against using the name _n_ as a loop variable. This variable is special in that it indicates the number of iterations the datastep has gone through. Usually it is also the sequence number of the record read with the set statement. So grant it its special purpose and leave it alone.
The log suggest that at a certain data row the variable _minym becomes missing, likely because of the value of start_yrmo. I would suggest to run only the first two statements of your datastep to investigate these values.
Consider using put statements in your code for debugging Like:
data wan (drop = _:);
set wan2;
_minym = input (put (start_yrmo, 6.), yymmn6.);
if missing(_minym) then put _all_;
...
Te log will show the value of all variables for that record in dataset wan2.
Consider using the datastep debugger. A great tool for investigating these pesky little data related problems and go to the bottom if it.
Hope this helps,
-- Jan.
Likely culprit data values:
data work.problemdata; set wan2 (keep= start_yrmo); _minym = input (put (start_yrmo, 6.), yymmn6.) ; if missing(_minym); run;
My money is on some "month" values of 00.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.