将文本文件内容直接导入宏变量。

huangapple go评论52阅读模式
英文:

Import txt file content straight into macro variable

问题

我正在编写一个宏来从我们的数据库中导入数据,通过对URL进行POST请求来访问。

我们的API令牌被保存为一个.txt文件,只有该令牌。我不想将这个令牌导入为SAS数据集,而是希望直接导入到一个宏变量中。

所以,一个示例:
我的文件"U:\API Tokens\example_token.txt"

D07034E4B64657B295BE96457AE890AF

我想将这个导入到SAS,并将其分配给一个宏变量token

英文:

I am writing a macro to import data from our database, accessed through a POST request to the URL.

Our API tokens are saved as a .txt-file, with only that token. I don't want to import this token as a SAS dataset, rather I would prefer to import directly into a macro variable.

So, an example:
My file "U:\API Tokens\example_token.txt":

D07034E4B64657B295BE96457AE890AF

I want to import this into SAS, and assign it to a macro variable token.

答案1

得分: 3

使用 _null_ 防止创建数据集:

pre
data null;
infile "/path/to/file" truncover;
input;
call symputx('TOKEN', INFILE);
run;


<details>
<summary>英文:</summary>

Use `_null_` to prevent a dataset from being created :

&lt;pre&gt;
data _null_ ;
  infile &quot;/path/to/file&quot; truncover ;
  input ;
  call symputx(&#39;TOKEN&#39;,_INFILE_) ;
run ;
&lt;/pre&gt;

</details>



huangapple
  • 本文由 发表于 2023年6月19日 16:51:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505063.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定