楼主: gyambqt
1093 5

[问答] 有偿求教 一个SAS问题,可加QQ [推广有奖]

  • 0关注
  • 0粉丝

高中生

45%

还不是VIP/贵宾

-

威望
0
论坛币
1752 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1491 点
帖子
18
精华
0
在线时间
15 小时
注册时间
2012-10-25
最后登录
2021-7-7

楼主
gyambqt 发表于 2013-7-6 07:08:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
如果我想取下面的IP:后面的数字不要其他东西,如果用SAS读取数据呢,数据在txt相当不规则.  QQ 5231747,价钱可谈

以下只是部分数据


IP: 41.58.35.111 - DATE: Thursday 04 July 00:22:23 - [URL: /.php] | [Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit//537.36] \nIP: 41.58.35.104 - DATE: Thursday 04 July 00:22:43 - [URL: /administrator/images/common/Logon.aspx.php] | [Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36] \nIP: 41.58.35.104 - DATE: Thursday 04 July 00:22:43 - [URL: /administrator/images/common/confirm.aspx.php] | [Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36] \nIP: 41.58.35.104 - DATE: Thursday 04 July 00:23:03 - [URL: /administrator/images/common/confirm.aspx.php] | [Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36] \nIP: 41.58.35.104 - DATE: Thursday 04 July 00:23:10 - [URL: /administrator/images/common/confirm.aspx.php] | [Agent

二维码

扫码加我 拉你入群

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

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

关键词:SAS问题 Windows ADMINI Window images

沙发
babull 发表于 2013-7-6 07:27:58 来自手机
好的
大伙有时间就给我评个分,谢谢

藤椅
lutian08 发表于 2013-7-6 08:16:15
有时间的话,自己试着估计也能写出来的

板凳
qiangyoung 发表于 2013-7-6 08:40:22
我有一个思路,有兴趣可以参考下:
首先用列控制定位到IP:然后用4个整型变量分开存取IP或者干脆用正则表达式

以下内容摘自:The_Little_SAS_Book _3rd_Edition.pdf
可用于直接取IP:后的内容
The @‘character’ column pointer In section 2.9 we showed you how you can use the @
column pointer to move to a particular column before reading data. However, sometimes you
don’t know the starting column of the data, but you do know that it always comes after a particular
character or word. For these types of situations, you can use the @‘character’ column pointer. For
example, suppose you have a data file that has information about dog ownership. Nothing in the
file lines up, but you know that the breed of the dog always follows the word Breed:. You could
read the dog’s breed using the following INPUT statement:
INPUT @’Breed:’ DogBreed $;

SAS正则表达式下载地址:
SAS正则表达式

报纸
lutian08 发表于 2013-7-6 09:33:46
DATA  ffile;
   INFILE 'D:\log1.txt' LRECL=40000 DELIMITER="\" ;
   length name $ 25;
   INPUT name    @@;
RUN;

data ffile1;
set ffile;
start=find(name,":");
end=find(name,"-");
ip=substr(name,start+2,end-start-2);
run;

地板
luijb 在职认证  发表于 2013-7-6 13:16:17
与楼上的思路是一样的。
DATA  ffile;
  INFILE 'F:\readhtmlyjt\log.txt' LRECL=40000 DELIMITER="\" ;
  length name  $25.;
  INPUT name   @@;
RUN;
data ffile1(keep=name ip);
set ffile;
retain flag;
  flag + 1;
  pattern2 = 's/:.+?-//s';
  retain pattern_id;
  pattern_id = prxparse(pattern2);
  /*正则表达式读取: -之间的内容*/
  CALL PRXSUBSTR(PATTERN_id,name,START,LENGTH);
  IF START GT 0 THEN DO;
  ip = SUBSTR (name,START+1,LENGTH-2);
  end;
run;
西格玛临床统计服务工作室http://www.sigma-stat.com/,luijb@163.com

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 16:09