BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alix1
Calcite | Level 5

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
Reeza
Super User

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;

View solution in original post

4 REPLIES 4
Reeza
Super User

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

https://video.sas.com/detail/videos/sas-analytics-u/video/4573016758001/creating-a-sas-table-from-a-...

 

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?


 

alix1
Calcite | Level 5
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;


Reeza
Super User

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;
alix1
Calcite | Level 5

Thank you, your help is very useful.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

Discussion stats
  • 4 replies
  • 4162 views
  • 1 like
  • 2 in conversation