楼主: bookbug
2557 5

[Stata高级班] STATA高级:使用ftp数据及字符串序列问题 [推广有奖]

  • 0关注
  • 88粉丝

教授

21%

还不是VIP/贵宾

-

威望
1
论坛币
497159 个
通用积分
157.5945
学术水平
94 点
热心指数
106 点
信用等级
82 点
经验
9732 点
帖子
730
精华
7
在线时间
192 小时
注册时间
2005-2-18
最后登录
2023-6-8

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

问题1:

    stata可以引用http协议下得数据,不知道对于ftp目录中的数据什么命令可以实现访问

问题2:

    循环中依次使用某数据序列中的数据时,可以先将数据存在一个矩阵中,但是矩阵不能存储字符串,同样的调用字符串的功能有没有办法实现呢。

    比如在一个地方写入31个省、市、自治区的名字,然后循环31次依次调用这31个字符串(它们的长度好像没什么规律)。

二维码

扫码加我 拉你入群

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

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

关键词:STATA高级 Stata tata 字符串 FTP 数据 序列 Stata FTP 字符

本帖被以下文库推荐

沙发
arlionn 在职认证  发表于 2008-11-30 09:51:00 |只看作者 |坛友微信交流群

Q1:

   这个问题此前统计局有位朋友也探讨过,不过好像没有什么好的办法。建议到 stata list(http://www.stata.com/statalist)中发个Email,那里集中了全世界的stata高人,应该会有解答。

Q2:

   若使用stata原来的矩阵功能(matrix命令),确实无法处理字符串。但自stata9以来,有了mata语句,可以在矩阵中处理字符串了。

   就你的问题而言,或许可以考虑先把31个省份的名称转换成代码(encode命令),然后再对这些代码(数字类型)进行循环操作即可。

使用道具

藤椅
arlionn 在职认证  发表于 2008-11-30 10:01:00 |只看作者 |坛友微信交流群

Bookbug:

   我到stata官方网站查询了这个问题(你可以在stata主页右上角搜索区输入 “ftp data”关键字进行搜索),似乎没有很好的解决办法。下面是相关信息:

Re: st: reading data from ftp site?


From  ariley@stata.com (Alan Riley)
To  statalist@hsphsun2.harvard.edu
Subject  Re: st: reading data from ftp site?
Date  Thu, 25 Jan 2007 12:08:46 -0600


Paulo Guimaraes (guimaraes@moore.sc.edu) would like to download data from an FTP site directly into Stata: > I would like to know if it is possible to read data directly from an ftp > site. > My interest in this is because I need to access some flat files at the BLS > web site. > Right now what I do is to open the file in my web browser and then save it > and insheet it into Stata. > For example, to read the employment time series for the state of Alabama I > need to open the file in my web browser > with the command: > ftp://ftp.bls.gov/pub/time.series/sm/sm.data.1.Alabama > and then save it and read it into Stata. > Is it possible to read the data directly from within Stata? Anders Alexandersson (andersalex@gmail.com) suggested that it may be possible to do this directly in Stata: > I don't think you need to resort to mapping. The user manual [U] 28.2 > suggests the Stata -copy- command for sharing other files than Stata > datasets (for which -use- is a direct solution). Although the URL > examples are for http, and I have not tried ftp, ftp is another type > of URL so it should work. Stata currently supports only the 'http' protocol for accessing files on the internet. URLs beginning with 'ftp://' and protocols other than 'http://' are not supported. Paulo should be able to do as Austin Nichols (austinnichols@gmail.com) suggested: > There are probably several platform-specific approaches. One is to > "map an ftp server as a drive" or whatever the equivalent operation is > in your OS. In various flavors of Windows, there are several apps > that can map a drive letter to an ftp server, at which point the > standard infiling commands should work fine. Depending on the operating system Paulo is using, command-line utilities such as 'curl' or 'wget' may also be available which support downloading data using a variety of protocols, including ftp. Paulo could use Stata's -shell- command to access such a command to download a file via ftp. Alan (ariley@stata.com) 

使用道具

板凳
bookbug 发表于 2008-12-2 14:16:00 |只看作者 |坛友微信交流群
多谢连博士回复

使用道具

报纸
bookbug 发表于 2008-12-12 09:50:00 |只看作者 |坛友微信交流群

又找到一个方法:http://www.stata.com/statalist/archive/2007-05/msg00494.html

st: how to make a string matrix


From  Kit Baum <baum@bc.edu>
To  statalist@hsphsun2.harvard.edu
Subject  st: how to make a string matrix
Date  Tue, 15 May 2007 11:55:07 -0400


sacrificial rutabaga

Along with Bill Gould's solution for using Mata to hold a "string matrix", also note that such a creature can be handled by using a set of locals:

local row1 a b c d e
local row2 f g h i j k l
local row3 m n o p
local row4 q r s t u v
local row5 w x y z

local row 3
local col 2
local element : word `col' of `row`row''
di "S[`row',`col'] is `element'"

Note that unlike standard matrices, such a 'matrix' can have a different number of elements per row.

Some may note the resemblance between this solution and an array of pointers to arrays.


Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* For searches and help try:
*
http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/

使用道具

地板
arlionn 在职认证  发表于 2008-12-17 08:48:00 |只看作者 |坛友微信交流群
Baum的确是个高手,呵呵。

使用道具

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

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-11-6 03:43