markdown 在SAS中创建/导入数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在SAS中创建/导入数据相关的知识,希望对你有一定的参考价值。

# Creating/Importing a file in SAS

--------

## Creating a dataset inside SAS

There is a simple way to add some data inside data step. 

It uses **datalines**

```sas
data d1;
input a b;
datalines;
1 2
2 3
4 5
2 2
5 76
4 2
;
run;```


```sas
proc print data = d1;
run;```


## Less variables, more data

When we have declared less variables but the input data is more. 


```sas
data work.test3;
input x y;
datalines;
1 2 55
3 2 112
5 3 223
3 1 4
5928 2 10
;
run;

proc print data = work.test3;
run;
```


## Assignment is tricky when variables are more and values are less

```sas
data work.test4;
input x y p q;
datalines;
1 2 55
3 4 77
5 6 99
7 8 33
9    10 44
;
run;

proc print data = work.test4;
run;
```

#### This won't assign any value to x, y. Will leave it blank. 

```sas
data test6;
input x y;
datalines;
1
;
run;
proc print data= test6;
run;
```

## Rules for datalines 

Datalines reads the data from one line and moves to the next line. 


## Linking a file in SAS

It uses **infile**

```sas
data work.test7;
infile 'e:\22jun\sp.txt';
input x y;
run;
```

## Create data without datalines

```sas
data work.test8;
x=12;
y=123;
run;

proc print data = work.test8;
run;
```

## Using inbuilt dataset

```sas
proc print data=sashelp.baseball;
run;
```

Type it slowly and it will show the list of all possible areas where you need to make this change. 

以上是关于markdown 在SAS中创建/导入数据的主要内容,如果未能解决你的问题,请参考以下文章

只读SAS视图(双击也是如此)

将下一个观察移动到前一列以在sas中创建三角形

使用 KnitR 以编程方式在 R 中创建 Markdown 表

如何在 markdown frontmatter 中创建字符串列表?

如何使用python在mysql中创建表和导入数据

Sas程序优化使用较少的工作空间