Professional Documents
Culture Documents
Macros
Macros
%put &raj.;
%let shivani=raj;
%put &shivani.;
%symdel shivani;
%put &shivani.;
%put &raj.;
%symdel raj;
%put &raj.;
/*************************************/
%let kiran= joginder262425;
%put &kiran.;
%put _all_;
%put _user_;
%let b=50;
%put 'the value of b is' &b.;
/*****************************/
%let a=4+5;
%put &a.;
/*********************************/
%let class=advance;
proc print data=sashelp.class;
title "The Level is &class.";
run;
%put &class.;
option symbolgen;
/* this is use when we don't want to write %put again & again. */
proc print data= sashelp.class;
title "The Level is &class.";
run;
/*********************************************/
%let p=1;
%let q=1;
%let r=&p+&q;
%put &r.;
/******************************************/
%put &syslast.;
%put &syserr.;
/***********************************/
%put &sysdate.;
%put &sysdate9.;
%let x=%substr(&sysdate9.,1,2);
%put &x.;
%let y=%substr(&sysdate9.,3,3);
%put &y.;
%let z=%substr(&sysdate9.,6,3);
%put &z.;
%let e=%substr(&sysdate9.,6,6);
%put &e.;
data test_%substr(&sysdate9.,6,4);
g=1;
run;
proc print;
run;
/************************************************/
%let Y=%substr("four score and seven", 6, 5);
%put &y.;
data f;
set sashelp.class;
run;
%put &syslast.;
%let str=a,b,c,d,e;
%put &str.;
/** Question:
%let y=%scan(&str.,2,^);
%put &y.;
**/
/* what will be written to the SAS log when the following %index statement
submitted? */
%let a=a very long value;
%let b=%index(&a, v);
%let x=%eval(1+2);
%put &x.;
%let x=%eval(1=2);
%put &x.;
%let x=%eval(2=2);
%put &x.;
/*it can't show a fractional output so return zero(0)*/
%let x=%eval(4/8);
%put &x.;
/******************************************************/
%put today();
%put %sysfunc(today());
/******************************************************/
%let myvar=1000;
%put the value of macro variable %str(&myvar) is &myvar;
%put the value of macro variable %nrstr(&myvar) is &myvar;
/**********************************************************/
/**
call symput= will create micro variable which not remove leading and trailing blank
call symputX= will remove leading and trailing blank
**/
data test;
call symput('mvar', 10);
run;
%put &mvar.;
data t1;
input name $ Num;
datalines;
a 10
b 11
c 12
;
run;
data _null_;
set t1;
call symput(name, num);
run;
%put _all_;
data _null_;
set t1;
call symputx(name, num);
run;
%put x&a. s&b. &c.;
data _null_;
set t1;
call symput(name, num);
run;
%put x&a. s&b. &c.;
/*********************question**************************/
%let y=10;
data _null_;
%let z=&y.;
run;
%put &y. &z.;
%let y=10;
data _null_;
call symputx('y', 20);
%let z=&y.;
run;
%put &y. &z.;