You are on page 1of 5

%LET raj= 230400;

%put &raj.;

%let shivani=raj;
%put &shivani.;

%symdel shivani;
%put &shivani.;
%put &raj.;
%symdel raj;
%put &raj.;

/*************************************/
%let kiran= joginder262425;

%put &kiran.;

%put _all_;

%let ranjeet= anusha50 anshu30;


%put &ranjeet.;
%symdel kiran;

%put _user_;

%let joginder =raj and ranjeet;


%put _user_;
%put _automatic_;
/********************************/
%let a=4+5;
%put &a.;

%let b=50;
%put 'the value of b is' &b.;

/*****************************/

proc print data= sashelp.class;


title "this report is printed on &sysdate9. &systime.";
run;
/** single quotes value is not valueble **/
proc print data= sashelp.class;
title 'this report 45 is printed on &sysdate9. &systime.';
run;
/****************************************/

%let a=4+5;
%put &a.;

/*if we want to sum the integer value then use %eval */


%let a=%eval(4+5);
%put &a.;
/* if we want to evaluate the fraction number then use %sysevalf */
%let c=%sysevalf(4+5.2);
%put &c.;

/*********************************/
%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.;

%put %substr("four score and seven", 6, 5);


%let z=%substr("four score and seven", 2, 3);
%put &z.;

%put %substr("four score and seven", 2, 3);

%let p=%substr("four score and seven", 1, 3);


%put &p.;

%put %substr("four score and seven", 1, 3);


/** ERROR: open codes statement recurrsion detecet ...... and now restart the
session. **/
/
***********************************************************************************
********************/

data f;
set sashelp.class;
run;
%put &syslast.;

%let y=%scan(&syslast, 2, .);


%put &y.;

%let y=%scan(x-ky, 2, -);


%put &y.;/** - is working as delimeter and use in scan function **/
/*****************************************/

%let str=a,b,c,d,e;
%put &str.;

/** Question:
%let y=%scan(&str.,2,^);
%put &y.;
**/

%put today is &sysday.;


%put today is %upcase(&sysday.);
/******************************/

/* 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);

%put v appears at position &b;


/******************************************************/

%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.;

/******************************************************/

/*%syseval= it gives upto 32 decimal value*/


%let x=%sysevalf(4/8);
%put &x.;

%let x=%sysevalf(4/8, boolean);


%put &x.;

%let x=%sysevalf(4/8, ceil);


%put &x.;

%let x=%sysevalf(4/8, floor);


%put &x.;
/*************************************************/

%put %sysfunc(today(), date9.);

%put today();
%put %sysfunc(today());
/******************************************************/

/*** macro quating funtions ***/


%let step=data test; x=1; run;
%put &step.;
/* if i want to write something with semicolan(;) then i have to use %str **/

%let step= %str(data test; x=1; run;);


%put &step.;

%let step =data test %str(;) x=1 %str(;) run %str(;);


%put &step.;

%let myvar=1000;
%put the value of macro variable %str(&myvar) is &myvar;
%put the value of macro variable %nrstr(&myvar) is &myvar;

/******** Special character which appears in pairs ***/


%let title= june's Report;
%put &title.;

%let title= %str(june's Report);


%put &title;

%let title= %str(june%'s Report);


%put &title;

/**********************************************************/

/**
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.;

You might also like