If you need the value of a variable rather than the
variable itself what would you use to load the value to a
macro variable?

Answers were Sorted based on User's Feedback



If you need the value of a variable rather than the variable itself what would you use to load the..

Answer / chaitanya

If we need a value of a macro variable then we must define
it in such terms so that we can call them everywhere in the
program. Define it as Global. There are different ways of
assigning a global variable. Simplest method is %LET.

Ex: A, is macro variable. Use following statement to assign
the value of a rather than the variable itselfe.g.

%Let A=xyz x="&A";

This will assign "xyz" to x, not the variable xyz to x.

Is This Answer Correct ?    1 Yes 0 No

If you need the value of a variable rather than the variable itself what would you use to load the..

Answer / damwal

Use CALL SYMPUT routine.
Below I show how to assign the value of 3rd observation of
variable name (94) to a macro variable named "macrovar1"

data test;
input name @@;
datalines;
1 21 94 444 5
;

data _null_;
set test (firstobs=3 obs=3);
call symput("macrovar1",name);
run;

%put &macrovar1; /*display*/

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SAS Interview Questions

Can we use where and having clauses in a single SAS program. ex: proc sql;     select a,b,c from test      where state in 'KA'      and having <some condition>. Is the above program run correctly, if not why ?     

4 Answers   UHG,


How would you determine the number of missing or nonmissing values in computations?

0 Answers  


what is the SAS/ACCESS and SAS/CONNECT?

9 Answers   Accenture, iFlex, TCS,


Given an unsorted data set, how to read the last observation to a new data set?

0 Answers  


how do you want missing values handled? : Sas programming

0 Answers  






how to change the execute of macro

0 Answers   Mind Tree,


What is the command used to find missing values?

0 Answers  


Give some examples where proc report’s defaults are same as proc print’s defaults?

0 Answers  


how can you get the single data set from the library(which has the number of data sets)?

3 Answers   Accenture, Deloitte,


what is option year cuttoff in sas

2 Answers   L&T,


Name statements that function at both compile and execution time?

1 Answers  


What can be the size of largest dataset in SAS?

0 Answers  


Categories