BookmarkSubscribeRSS Feed
u58469353
Calcite | Level 5

I am using a macbook for class and our instructor provides xlsx files for us to use in SAS. I feel like something is going wrong with the files when I download them onto my computer. For instance, I made a graph for class recently and the graph would not appear when I executed the code. I had to go in and change the size to at least 10in by 10 in to get the graph to display. And when the graph actually displayed the bottom of the scatterplot had a ton of jumbled lines that almost looked like they mirrored a gradually decreasing line underneath the scatterplot itself.

 

Now I am attempting to display the proc means of the dataset, and I keep getting errors that say the variables don't exist, or if I don't specify variables, only the number of observations is displayed when I execute the code. 

 

proc means data=work.import mean stddev;
var B;
run;
ERROR: Variable B in list does not match type prescribed for this list.
 
Any help would be appreciated. The graph I created appears like this. 
 
Messed up graph.png
7 REPLIES 7
Tom
Super User Tom
Super User

What do your problems have to do with XLSX files?

Your posted code is referencing a SAS dataset, named WORK.IMPORT.

 

Is it possible you actually tried to generate a delimited file (aka CSV file) from Excel on a MAC and then tried to read that file using PROC IMPORT in SAS?  If so then watch out as Excel never learned that Mac OS is now a version of unix.  So it will generate text files that use only carriage return ('0D'x) as the end of line characters instead of the line feed ('0A'x) used by Unix or the CR+LF ('0D0A'x) used by DOS/Windows.  So either take more care in the format you pick the SAVE AS window in Excel or use the TERMSTR=CR option on the FILENAME or INFILE statement in SAS when reading the text file in SAS.

 

Note if you just saved the file as an actual XLSX file and asked SAS to import that then you would not have that issue.

u58469353
Calcite | Level 5

I don't have excel on my computer. My instructor posts xlsx files each week for us to import into SAS. So I don't actually save anything on excel, I just download the files my instructor posts and they come up on my macbook in the numbers application. I've tried to use xlsx files, and I've also tried to use csv files to see if there was any difference. I'm very new to SAS studio. I'm using SAS on demand for academics. 

Reeza
Super User
Are you using SAS University Edition, Academics on Demand, or your own custom SAS version installed on a Windows/Unix Partition on your Mac?

Please show the rest of your code. The issue shown has nothing to do with Excel most likely and is related to something earlier in your code - likely a bad data import. When you check the imported data file directly is it what you expect?
u58469353
Calcite | Level 5

I'm using SAS on demand for academics. And I uploaded the xlsx file onto SAS and then imported the file. I don't actually have excel on my computer, and I'm not creating the dataset in excel, I am just downloading an xlsx file that my instructor posts and then uploading/importing the file onto SAS

Tom
Super User Tom
Super User

How did you import the file into SAS dataset(s) once you had it on the SAS server?  Did you run SAS code? What code?  Did you push buttons in the SAS/Studio interface?  What buttons?

 

You can read an XLSX file in two ways in SAS.  Either with PROC IMPORT or by using the XLSX engine on a libref.

 

 

u58469353
Calcite | Level 5

This is the code I imported. I uploaded the file onto sas using the upload button. And then I clicked the xlsx file that I uploaded to import the file. Once I clicked the file in order to import it, this code appeared

 

%web_drop_table(WORK.IMPORT);


FILENAME REFFILE '/home/u58469353/MIS445/MIS445MORTGAGE30US.xlsx';

PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT; RUN;


%web_open_table(WORK.IMPORT);

u58469353
Calcite | Level 5

%web_drop_table(WORK.IMPORT);


FILENAME REFFILE '/home/u58469353/MIS445/MIS445MORTGAGE30US.xlsx';

PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT; RUN;


%web_open_table(WORK.IMPORT);

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1085 views
  • 0 likes
  • 3 in conversation