This may work fine or give you the general idea of how it would work.
%marco sensitivityfactoring( varname, UporDown, libin, datasetin, libout, datasetout);
/*comment explaining the macro program parameters above*/
/*marco (variable name, the words UP or DOWN,
path to library/folder where your data are, datasetin is the name of the dataset,
path to library/folder where your new data will go, datasetin is the name of the new dataset,*/
/*Macro program*/
/* define libname*/
libname datain "&libin."; /* path to library/folder where your data are.*/
/*bring data into work directory*/
data haveoriginal;
set datain..&datasetin.; /* the & and period(s) (.) here are important*/ /* datasetin is the name of the dataset */
run;
%if "&UporDown."="UP" %then %let Sensitivityfactor=1.1;
/* we are moving the variable data up 10%*/
%else %if "&UporDown."="DOWN" %then %let Sensitivityfactor=0.9;
/* we are moving the variable data down 10%*/
/* define libname*/
libname dataout "&libout."; /* path to library/folder where your data are.*/
data daatout.&datasetout.;
set haveoriginal;
/* we know what variable we want to change because it's name is in this macro parameter variable name "varname"*/
&varname.=&varname.*&Sensitivityfactor.;
run;
/* we are done now.*/
%mend; /* we close the macro program. We only need to run the above code once to start per session*/
/* now we call our macro program like so.*/
%sensitivityfactoring(var1, UP, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var1, DOWN, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var2, UP, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var2, DOWN, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var3, UP, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var3, DOWN, C:\path location of file, data1, C:\outputpath, newdatasetname);
%marco sensitivityfactoring( varname, UporDown, libin, datasetin, libout, datasetout);
/*comment explaining the macro program parameters above*/
/*marco (variable name, the words UP or DOWN,
path to library/folder where your data are, datasetin is the name of the dataset,
path to library/folder where your new data will go, datasetin is the name of the new dataset,*/
/*Macro program*/
/* define libname*/
libname datain "&libin."; /* path to library/folder where your data are.*/
/*bring data into work directory*/
data haveoriginal;
set datain..&datasetin.; /* the & and period(s) (.) here are important*/ /* datasetin is the name of the dataset */
run;
%if "&UporDown."="UP" %then %let Sensitivityfactor=1.1;
/* we are moving the variable data up 10%*/
%else %if "&UporDown."="DOWN" %then %let Sensitivityfactor=0.9;
/* we are moving the variable data down 10%*/
/* define libname*/
libname dataout "&libout."; /* path to library/folder where your data are.*/
data daatout.&datasetout.;
set haveoriginal;
/* we know what variable we want to change because it's name is in this macro parameter variable name "varname"*/
&varname.=&varname.*&Sensitivityfactor.;
run;
/* we are done now.*/
%mend; /* we close the macro program. We only need to run the above code once to start per session*/
/* now we call our macro program like so.*/
%sensitivityfactoring(var1, UP, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var1, DOWN, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var2, UP, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var2, DOWN, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var3, UP, C:\path location of file, data1, C:\outputpath, newdatasetname);
%sensitivityfactoring(var3, DOWN, C:\path location of file, data1, C:\outputpath, newdatasetname);
... View more