Hi Guys !!
Objective : I want to add a dummy field (BO_EXEMPTION_IND) that doesn't exists in my current dataset . But I want that to come as a field in my exported file/Outfile ( CSV file ) as before the code drop I want to perform my internal testing .
Below is the piece of code where in KEEP=OPTION I am mentioning all my fields which I want.
%macro c; (KEEP =CRS_ACCT_NBR CRS_CUSTOMER_TYPE CRS_APPLICATION_ID CRS_CIP_SSN_TAX_ID CRS_CIP_SSNT_VE_SRC_CD CRS_CIP_CONFIRMATI_CD CRS_AGENT_NOTES_DAT CRS_APPL_SSN_TAX_ID CRS_GOV_TYPE_ID BO_EXEMPTION_IND) %mend; data thd_cipcru; set thd.cipcrussn&DT.; run; data all_port_cipcru; set thd_cipcru; CRS_CIP_NAM_VER_DTE1=input(CRS_CIP_NAM_VER_DTE, mmddyy8.); CRS_CIP_DOB_VER_DTE1=input(CRS_CIP_DOB_VER_DTE, mmddyy8.); CRS_CIP_ADR_VER_DTE1=input(CRS_CIP_ADR_VER_DTE, mmddyy8.); CRS_CIP_SSNT_VER_DTE1=input(CRS_CIP_SSNT_VER_DTE, mmddyy8.); format CRS_CIP_NAM_VER_DTE1 mmddyyd10. CRS_CIP_DOB_VER_DTE1 mmddyyd10. CRS_CIP_ADR_VER_DTE1 mmddyyd10. CRS_CIP_SSNT_VER_DTE1 mmddyyd10.; drop CRS_CIP_NAM_VER_DTE CRS_CIP_DOB_VER_DTE CRS_CIP_ADR_VER_DTE CRS_CIP_SSNT_VER_DTE; rename CRS_CIP_NAM_VER_DTE1=CRS_CIP_NAM_VER_DTE; rename CRS_CIP_DOB_VER_DTE1=CRS_CIP_DOB_VER_DTE; rename CRS_CIP_ADR_VER_DTE1=CRS_CIP_ADR_VER_DTE; rename CRS_CIP_SSNT_VER_DTE1=CRS_CIP_SSNT_VER_DTE; run; proc sort data =all_port_cipcru nodupkey; by _all_; run; data all_port_cipcru; retain CRS_ACCT_NBR CRS_CUSTOMER_TYPE CRS_APPLICATION_ID CRS_CIP_SSN_TAX_ID CRS_CIP_SSNT_VE_SRC_CD CRS_CIP_CONFIRMATI_CD CRS_AGENT_NOTES_DAT CRS_APPL_SSN_TAX_ID CRS_GOV_TYPE_ID BO_EXEMPTION_IND; set all_port_cipcru %c; run; proc export data =all_port_cipcru outfile="/etl/home/rrtqarun/data/aml/Datasets/cardholder/dataset_frequency/cda_can_rpl_cipcrussn_&DT2..csv" dbms=csv replace; delimiter= '|'; run;
Can you guys please help me ?? that how can I create a field which doesn't actually exists in the current dataset but exported in my outfile.
... how can I create a field which doesn't actually exists in the current dataset but exported in my outfile
Any variable you want to export via PROC EXPORT must be contained in the data set you are exporting. If you don't want those variables in data set ALL_PORT_CIPCRU, don't put them in there. Put those variables in a different data set.
data all_port_cipcru_temp;
set thd_cipcru;
CRS_CIP_NAM_VER_DTE1=input(CRS_CIP_NAM_VER_DTE, mmddyy8.);
CRS_CIP_DOB_VER_DTE1=input(CRS_CIP_DOB_VER_DTE, mmddyy8.);
CRS_CIP_ADR_VER_DTE1=input(CRS_CIP_ADR_VER_DTE, mmddyy8.);
CRS_CIP_SSNT_VER_DTE1=input(CRS_CIP_SSNT_VER_DTE, mmddyy8.);
format CRS_CIP_NAM_VER_DTE1 mmddyyd10. CRS_CIP_DOB_VER_DTE1 mmddyyd10. CRS_CIP_ADR_VER_DTE1 mmddyyd10. CRS_CIP_SSNT_VER_DTE1 mmddyyd10.;
drop CRS_CIP_NAM_VER_DTE CRS_CIP_DOB_VER_DTE CRS_CIP_ADR_VER_DTE CRS_CIP_SSNT_VER_DTE;
rename CRS_CIP_NAM_VER_DTE1=CRS_CIP_NAM_VER_DTE;
rename CRS_CIP_DOB_VER_DTE1=CRS_CIP_DOB_VER_DTE;
rename CRS_CIP_ADR_VER_DTE1=CRS_CIP_ADR_VER_DTE;
rename CRS_CIP_SSNT_VER_DTE1=CRS_CIP_SSNT_VER_DTE;
run;
proc export data =all_port_cipcru_temp
outfile="/etl/home/rrtqarun/data/aml/Datasets/cardholder/dataset_frequency/cda_can_rpl_cipcrussn_&DT2..csv"
dbms=csv
replace;
delimiter= '|';
run;
proc delete data=all_port_cipcru temp;
run;
You can also use data set options Drop or Keep in any procedure to limit the variables used by the procedure.
So with your shown code the macro C could be used to provide the Keep statement as data set option for proc export if that is the intent.
proc export data =all_port_cipcru %c outfile="/etl/home/rrtqarun/data/aml/Datasets/cardholder/dataset_frequency/cda_can_rpl_cipcrussn_&DT2..csv" dbms=csv replace; delimiter= '|'; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.