Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Import data and add a new variable

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 08-15-2018 12:59 PM
(3539 views)

I am starting to work with SAS and I would like you to please help me resolve the following questions.

How do I transform an imported database from Excel into a matrix?

How can I add a column vector of ones?

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It looks like you're using IML - that isn't my forte so I'd suggest you move that to an IML forum.

Here's some short cut references that may help:

https://blogs.sas.com/content/iml/2015/09/28/create-test-matrices.html

If it was a data step it would be:

```
data want;
do Row_Number=1 to 100;
constant=1;
x=rand('integer', 5, 10);
*create a random number between 5 and 10;
output;
end;
run;
```

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Are you planning to work with SAS/IML or with base programming?

If you're using Base Programming here are some instructions on how to import your data and to create a new column.

Import a CSV file

Import an Excel file

https://video.sas.com/detail/video/4664358166001/using-the-import-data-utility-in-sas-studio

Create a new column

https://video.sas.com/detail/videos/sas-analytics-u/video/4573023399001/creating-a-new-column-in-sas

If you're trying to do this via IML which is more similar to R/Python and matrices/arrays in mathematics, then you would first import your data and then load it into a matrix.

@alix1 wrote:

I am starting to work with SAS and I would like you to please help me resolve the following questions.

How do I transform an imported database from Excel into a matrix?

How can I add a column vector of ones?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for your help.

I would like to know how I do to build a vector that contains a one and a

random value of a uniform distribution. I tried to do it in the following

way, but it generates an error.

proc iml;

x={1 RAND("UNIFORM")};

print x;

I would like to know how I do to build a vector that contains a one and a

random value of a uniform distribution. I tried to do it in the following

way, but it generates an error.

proc iml;

x={1 RAND("UNIFORM")};

print x;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It looks like you're using IML - that isn't my forte so I'd suggest you move that to an IML forum.

Here's some short cut references that may help:

https://blogs.sas.com/content/iml/2015/09/28/create-test-matrices.html

If it was a data step it would be:

```
data want;
do Row_Number=1 to 100;
constant=1;
x=rand('integer', 5, 10);
*create a random number between 5 and 10;
output;
end;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you, your help is very useful.

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.