please describe output of below mention code

Reply
New Contributor
Posts: 2

please describe output of below mention code

[ Edited ]

data _null_;

set sashelp.class end = last;

call symput ('sname' || trim(left(_n_)) , name);

if last then call symput ('var_count' , _n_);

run;

 

%macro newvar;

data output;

set sashelp.class;

%do = 1 %to &var_count;

&&sname&i = (name = "&&sname&i");

%end;

 

%newvar;

%mend;

Super User
Posts: 24,010

Re: please describe output of below mention code

Posted in reply to tarun_2202
Did you run it? Also....you have some interesting variable names that make me not want to answer your question.
New Contributor
Posts: 2

Re: please describe output of below mention code

Hi,
In Output of this code, dummy variable created with same name as value of name variable having value of 0 and 1 ...
Super User
Posts: 10,574

Re: please describe output of below mention code

Posted in reply to tarun_2202

You can achieve something similar without macro coding:

data class;
set sashelp.class;
value = 1;
run;

proc transpose data=class out=want (drop=_name_);
by name age sex weight height;
var value;
id name;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 10,850

Re: please describe output of below mention code

Posted in reply to tarun_2202

It is the same as 

 

data have;
 set sashelp.class;
 dummy=1;
run;
proc logistic data=have outdesign=want(drop=intercept dummy) outdesignonly;
class name/param=glm;
model dummy=name;
run;
Ask a Question
Discussion stats
  • 4 replies
  • 71 views
  • 0 likes
  • 4 in conversation