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

what is cummaltive frequency,and varience in proc unviarte

1 Answers   L&T,


What was the last computer book you purchased? Why?

0 Answers   Oracle,


/* This is example of age caluculate wihtout to display perfect days and years in output window */ data age; retain dob "12jun2003"d now "24may2011"d; age1=now-dob; age=(now-dob)/365.25; years=int(age); days1=round((age-years)*365.25); months=month(now)-1; if days1 gt 30 and months in(12,10,8,6,4,2)then do; month1=days1/30.4375; month=int(days1/30.4375); if day(now)=1 then days=1; else days=round((month1-month)*30.4375)+1; drop days1 month1 month; end; else if days1 gt 30 and months in (1,3,5,7,9,11)then do; month1=days1/30.4375; month=int(days1/30.4375); if day(now)=1 then days=1; else days=round((month1-month) *30.4375); drop days1 month1 month; end; drop age age1; proc print data=age; format dob now date.; run;

1 Answers   Emerio,


How would you invoke a macro? : sas-macro

0 Answers  


Can anyone help me about SAS Realtime scenarios in Clinical field

0 Answers  






How do you read in the variables that you need?

5 Answers  


1.What is the difference between _NULL_ , _ALL_, and _N_? 2.What are the uses of _NULL_ using in Data Steps? Can we _NULL_ in Proc Steps also? 3.How do call the macro variable in Data Steps? 4.How to construct Pivot tables in Excel Using SAS?

3 Answers  


Which are SAS Windows Clients & SAS Java Clients

3 Answers   TCS,


In SAS explain which statement does not perform automatic conversions in comparisons?

0 Answers  


firstobs and obs are working only option wise,but we are using infile statement with firstobs and obs in a statement wise? so firstobs,obs working at options and statemnts or not?

1 Answers  


do you need to know if there are any missing values? : Sas programming

0 Answers  


i have a data set with 20 observations i want label from 8 to 15 observations ? how you create this one.

6 Answers   CTS,


Categories