楼主: bisake
2435 9

我要打印出宏变量clist1 至clist999要怎么改呀? [推广有奖]

  • 0关注
  • 3粉丝

已卖:1941份资源

本科生

53%

还不是VIP/贵宾

-

威望
0
论坛币
18361 个
通用积分
0.1288
学术水平
3 点
热心指数
4 点
信用等级
3 点
经验
1136 点
帖子
95
精华
0
在线时间
94 小时
注册时间
2007-9-14
最后登录
2019-8-16

楼主
bisake 发表于 2012-10-14 16:41:39 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
proc sql noprint;                                                                                                                       
  select name                                                                                                                           
  into :clist1-:clist999                                                                                                               
  from dictionary.columns                                                                                                               
  where libname = 'SASHELP' and memname = 'CLASS';                                                                                      
quit;                                                                                                                                   
%put &clist1.;                                                                                                                          
%put &clist2.;                                                                                                                          
请问我要打印出宏变量clist1 至clist999要怎么改呀?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:list IST Dictionary proc sql libname 打印 sql

沙发
Imasasor 发表于 2012-10-14 19:28:49
%macro print;
data _null_;
%do i=1 %to 100;
%put &&clist&i;
%end;
run;
%mend;
%print;
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

藤椅
bisake 发表于 2012-10-14 19:53:40
Imasasor 发表于 2012-10-14 19:28
%macro print;
data _null_;
%do i=1 %to 100;
只能用循环,不能用类似于变量列表的形式吗?

板凳
bisake 发表于 2012-10-14 19:58:59
Imasasor 发表于 2012-10-14 19:28
%macro print;
data _null_;
%do i=1 %to 100;
另外还有个程序:
proc sql noprint;                                                                                                                        
   select count(distinct sex)                                                                                                            
      into :n                                                                                                                           
      from sashelp.class;                                                                                                               
   select distinct sex                                                                                                                  
      into :type1 - :type%left(&n)                                                                                                      
      from sashelp.class;                                                                                                               
quit;                                                                                                                                    
%put &n.;                                                                                                                                
%put &type1.;
%put &type2.;

最后的 &type2. 我想使用引用n的形式,如%put &type%left(&n)
这里我总是弄不好。请问你有办法吗?

报纸
bobguy 发表于 2012-10-14 23:49:10
Take out the noprint option on SQL

地板
bisake 发表于 2012-10-18 12:49:10
bobguy 发表于 2012-10-14 23:49
Take out the noprint option on SQL
I want to output the value by using “%put" function, say %put &type%left(&n)

7
yongjiang2 发表于 2012-10-18 20:22:25
bisake 发表于 2012-10-18 12:49
I want to output the value by using “%put" function, say %put &type%left(&n)
%macro print;
proc sql noprint;                                                                                                                        
   select count(distinct sex)                                                                                                            
      into :n                                                                                                                           
      from sashelp.class;                                                                                                               
   select distinct sex                                                                                                                  
      into :type1 - :type%left(&n)                                                                                                      
      from sashelp.class;                                                                                                               
quit;                                                                                                                                    

data _null_;
%do i=1 %to &n.;
%put &&type&i.;
%end;
%mend ;
%print

8
bobguy 发表于 2012-10-20 07:35:46
Imasasor 发表于 2012-10-14 19:28
%macro print;
data _null_;
%do i=1 %to 100;
This is a right one.

%macro print1(mvar,n);

%do i=1 %to &n;
%put "&&&mvar.&i";
%end;

%mend;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
pobel + 1 + 1 + 1 我很赞同

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

9
pobel 在职认证  发表于 2012-10-20 07:45:44
bisake 发表于 2012-10-14 19:58
另外还有个程序:
proc sql noprint;                                                                ...
是不是 %put &&type&n;
和谐拯救危机

10
bobguy 发表于 2012-10-20 07:46:10
yongjiang2 发表于 2012-10-18 20:22
%macro print;
proc sql noprint;                                                                   ...
Here is better one.


%macro print(clist,dsn,var);
proc sql noprint;                                                                                                                                                                                                                                    
   select distinct &var                                                                                                                  
      into :&clist.1 - :&clist.32000                                                                                                     
      from &dsn
    ;                                                                                                               
                                                                                                                                   
%do i=1 %to &sqlobs;
%put >>>&&&clist.&i<<<;
%end;

quit;
%mend;
%print(mymvar,sashelp.class, sex)

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-27 20:23