Hi,
I was running this piece of code that I was given and I keep getting warnings that say a few of the variables are uninitialized. I tried a few things to correct this but nothing worked for me. I was wondering if anyone would have any ideas on this. Any help is appreciated.
Thank you!
Well, let's take a look at the first one, notDone.
It appears in the code to be used, not calculated, but if its uninitialized that means it's not in the input data set. Most likely you have the variable name incorrect for some reason or are using the incorrect source data set.
So I would check your input data sets where the variable NotDOne should exist and verify if it first exists.
You can run a proc contents on your input data set to see the names. Look at the labels and variable names and make sure you're using the variable name, not the label.
proc contents data=adverse;
proc contents data=drugadm;
run;
@Patelbb wrote:
Hi,
I was running this piece of code that I was given and I keep getting warnings that say a few of the variables are uninitialized. I tried a few things to correct this but nothing worked for me. I was wondering if anyone would have any ideas on this. Any help is appreciated.
Thank you!
318 data adverse2(keep= sitenum patnum aename aesev fromdtc todtc sday);
319 merge adverse(in=inae)
320 drugadm(in=infdrg);
321 **drgadm (in=infdrg)**ERROR;
322 by usubjid;
323
324 /* Only keep the records that are in AE */
325 if inae;
326
327 /* Only process these steps on the records that have an actual event, use */
328 /* none box for determining this */
329 if (notdone ne 1) then do;
330 end; **ERROR;
331
332 /* Create Character Date since the date can be partial */
333 /* If Date is unknown then use UU to represent it */
334 if (fromdtdd eq .) then fday = 'UU' ;
335 else fday = put(fromdtdd,z2.);
336
337 if (fromdtmm eq .) then fmon = 'UU';
338 else fmon = put(fromdtmm,z2.);
339
340 if (fromdtyy eq .) then fyer = 'UUUU';
341 else fyer = put(fromdtyy, 4.);
342
343 /* Create character Onset date */
344 fromdtc = fyer || '/' || fmon || '/' || fday;
345
346 /* If the whole date is unknown then have it say so */
347 if (fromdtc eq 'UUUU/UU/UU') then fromdtc = 'Unknown';
348
349 /* Do the same thing for Stop date */
350 if (todtdd eq .) then tday = 'UU' ;
351 else tday = put(todtdd,z2.);
352
353 if (todtmm eq .) then tmon = 'UU';
354 else tmon = put(todtmm,z2.);
355
356 if (todtyy eq .) then tyer = 'UUUU';
357 else tyer = put(todtyy, 4.);
358
359 /* Create character End date */
360 todtc = tyer || '/' || tmon || '/' || tday;
361
362 /* If the whole date is unknown then have it say so */
363 if (todtc eq 'UUUU/UU/UU') then todtc = 'Unknown';
364
365 /* If the adverse Event is ongoing then overwrite the unknown piece*/
366 if (aeong eq 1) then todtc = 'Ongoing';
367
368
369 /* We have a character date...but now lets use the Numeric date to see when the event
370 occurred related to the start of study medication */
371 /* We can only do this for valid dates, not partial */
372 if (fromdate gt .Z) then sday = (fromdate - fdrgdate) +1;
373 run;NOTE: Variable notdone is uninitialized.
NOTE: Variable fromdtdd is uninitialized.
NOTE: Variable fromdtmm is uninitialized.
NOTE: Variable fromdtyy is uninitialized.
NOTE: Variable todtdd is uninitialized.
NOTE: Variable todtmm is uninitialized.
NOTE: Variable todtyy is uninitialized.
NOTE: Variable aeong is uninitialized.
NOTE: Variable fromdate is uninitialized.
NOTE: Variable fdrgdate is uninitialized.
WARNING: The variable sitenum in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable patnum in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable aename in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 297 observations read from the data set WORK.ADVERSE.
NOTE: There were 77 observations read from the data set WORK.DRUGADM.
NOTE: The data set WORK.ADVERSE2 has 297 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.07 seconds
cpu time 0.06 seconds
If there was just one variable uninitialized, I would agree with @Reeza's first suggestion ... maybe the variable name was spelled incorrectly. But when 10 variables are uninitialized, it means her second suggestion is the right one. Your incoming data sets are just plain wrong. They are supposed to contain these 10 variables, but they don't. Based on these messages, there is nothing to indicate anything is wrong with the program. It's the data that has the wrong variables in it.
Thank you guys for your helpful replies. I will look into the data sets and try to fix this.
Concur with all the others, a clear case for Maxim 3.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.