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

how can you put a "trace" in your program? : Sas programming

0 Answers  


6) Explain about below automatic variables a) _N_ b) _ERROR_ c) _CHAR_ d) _NUMERIC_ e) _ALL_ f) FIRST.BY VARIABLE g) LAST.BY VARIABLE h) _NAME_ i) _TYPE_ j) _FREQ_ k) _STAT_ l) _BREAK

1 Answers   IBM, SAS,


What is the difference between the proc sql and data step?

0 Answers  


How do you add a number to a macro variable? : sas-macro

0 Answers  


What system options would you use to help debug a macro? : sas-macro

0 Answers  






if a program has some 1000 or more line and how to know whether the syntax of the particular code is correct without checking it manually

4 Answers   Accenture,


Are the preferred term counts are always equal to Body system counts? If so, Why are they equal if not why they are not equal?

1 Answers   Icon,


Suppose there is a SAS dataset with following values - Parent Child A B B C D E F G G H H I and so on….. This goes onto 1000s of observations/rows. Now how do we identify from this dataset Grandparents and Grandchildrens ?

5 Answers   American Express, Barclays,


In which format does Date stores in sas..? What is the use of DATE in SAS.?

3 Answers   TCS,


what do the mod and int function do? What do the pad and dim functions do? : Sas programming

0 Answers  


how we can call macros with in data step?

17 Answers   Allianz, ManPower,


What do you code to create a macro? : sas-macro

0 Answers  


Categories