LibName trx SPDE "/.../transaction/" ;
%Let varToKeep =
system lineOfBusiness distribution company companyDivision region province accountingYear accountingYearMonth writtenPremium writtenUnit driverType ;
Data harmony_trx ;
Set trx.prm_trx_: (Keep=&varToKeep. );
Where accountingYear ge 2024 And accountingYearMonth LE 202509;
If distribution = 'Prestige' Then distribution = 'Broker';
If driverType = 'Occasional' Then writtenUnit = 0;
Run;
proc freq data=harmony_trx;
table driverType;
run;
the log file:
29
30 %Let varToKeep =
31 system lineOfBusiness distribution company companyDivision region province accountingYear accountingYearMonth
31 ! writtenPremium writtenUnit driverType ;
32
33 Data harmony_trx ;
34 Set trx.prm_trx_: (Keep=&varToKeep. );
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable driverType in the DROP, KEEP, or RENAME list has never been referenced.
35 Where accountingYear ge 2024 And accountingYearMonth LE 202509;
36
37 If distribution = 'Prestige' Then distribution = 'Broker';
38 If driverType = 'Occasional' Then writtenUnit = 0;
39 Run;
How to solve that issue because the driverType variable is really into the dataset
Your SET statement is reading in multiple data sets. It looks like at least some of the data sets do not have the driverType variable.
If you want to turn off this warning message, you can set the system option DKRICOND=NOWARNING. But records from the data sets which do not have this variable will still end up with a missing value.
Your SET statement is reading in multiple data sets. It looks like at least some of the data sets do not have the driverType variable.
If you want to turn off this warning message, you can set the system option DKRICOND=NOWARNING. But records from the data sets which do not have this variable will still end up with a missing value.
It is a good idea. I have 14 datasets to check, using proc contents. I will come back after to let you know what I have found
@alepage wrote:
I have 14 datasets to check, using proc contents.
For future checks like this (especially if more datasets are involved) you may want to consider querying DICTIONARY.COLUMNS rather than reviewing a lot of PROC CONTENTS output:
/* List all TRX.PRM_TRX_... datasets not containing variable driverType */ proc sql; select memname from dictionary.columns where libname='TRX' & memname eqt 'PRM_TRX_' group by 1 having max(upcase(name)='DRIVERTYPE')=0; quit;
As an aside, you might want to consider use of "not quite a date" variable like your "AccountingYearMonth" with apparent plain numeric values of 202509. Use an actual date value that represents the first day of the month to allow use of the SAS functions that will deal with increments and intervals . You can assign a format to the values that would have a default appearance of YYYYMM.
Your code
accountingYearMonth LE 202509
would become
accountingYearMonth LE "01Sep2025"D
which is, in my opinion, a bit clearer to follow the intent of the code.
SAS understands dates for many of the graphing procedures to do things like place tick marks at month or quarter intervals but graphing something with values like 202509 means a big gap between 202512 and 202601.
Plus the modeling and analysis procedures can use the intervals.
Not to mention simple things like the functions such as Quarter that would let you select a calendar quarter or a minor format change in a report could change the intervals from monthly to quarterly or annually
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.