In this question, I rename the numeric variable phone to
numphone and then try use phone=put(numphone,comma16.) to
store the numeric value numphone as a string value in phone.
But I get a warning tha numphone already exists and in the
data sat phone doesnt exist and numphone is set to missing. Why?


data names_and_more;
input Name $20.
Phone : comma16.
Height & $10.
Mixed & $8.;
Name = tranwrd(Name,' ',' ');
rename phone = numphone;
phone = put(numphone,comma16.);
datalines;
Roger Cody 9,087,821,234 5ft. 10in. 50 1/8
Thomas Jefferson 3,158,488,484 6ft. 1in. 23 1/2
Marco Polo 8,001,234,567 5Ft. 6in. 40
Brian Watson 5,183,551,766 5ft. 10in 89 3/4
Michael DeMarco 4,452,322,233 6ft. 76 1/3
;



In this question, I rename the numeric variable phone to numphone and then try use phone=put(numpho..

Answer / kumaraswamy maduri

Yes you are right.

The way you coded tells the compiler to do two actions
simultaneosly on the PDV. The renaming will be done once
the data step is closed.

data t;
set names_and_more(rename=(phone=numphone));
phone = put(numphone,comma16.);
run;

In the above example which uses the same data that you
gave, this works the way you wanted. Dataset options work
on the dataset not on the PDV.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SAS Interview Questions

how to import HTML files into SAS datasets?

3 Answers   HP,


how to do user inputs and command line arguments in sas?

0 Answers   D&B, TCS,


what is option year cuttoff in sas

2 Answers   L&T,


How will you assign all the variables of an dataset into a macro variable separated by a space? For example if a dataset has variables A,B,C. Assign them to a macro variable X as X=A B C

3 Answers   Accenture, Oracle,


what are different analysis datasets you created and what are the new variables created

2 Answers   Sciformix,






How you can read the variables that you need?

0 Answers  


Explain the message 'Merge has one or more datasets with repeats of by variables'.

5 Answers  


What procedure you used to calculate p-value?

2 Answers   Accenture, Quintiles,


Please, anyone, let me know the style or an example of using 'by='/'by' variable of a PDV(Program Data Vector)

3 Answers   Verinon Technology Solutions,


what is the difference between proc report and proc format?

7 Answers   CTS,


1.we can execute a macro with in a macro,by using call symput and symget can any one give me one example? 2.We can create the macro variables by using %let,%do,macro parameters,INTO clause in proc sql and call symput, can any one give me example to create macro variable with INTO clause and call symput? 3.

1 Answers  


what is broad cast agent? : Sas-bi

0 Answers  


Categories