BookmarkSubscribeRSS Feed
deleted_user
Not applicable
hello,

I import an excel datafile and stored it permnanently in same location



PROC IMPORT OUT=WORK.SAS1/*Store the data in the WORK file once imported*/
DATAFILE= "C:\CWA\SAS.xls"/*search the file SAS.xls in "C:\CWA"*/
DBMS=EXCEL REPLACE;
SHEET="Review"/*Import the sheet Review from the file SAS.xls*/ ;
GETNAMES=YES;
MIXED=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

proc print data=SAS1;
run;

libname dis "C:\SAS\"/*Put the SAS.xls file into the directory "C:\SAS"*/ ;

proc import datafile="C:\SAS\SAS.xls" out=dis.mySAS replace/*convert the file SAS.xls into the SAS datafile "mySAS"*/;
run;


PROC Contents data=dis.mySAS;
RUN;

Proc print data=dis.mySAS;
RUN;

libname dis "C:\SAS\";
proc boxplot data=dis.mySAS;
plot Score*(GHz Price Processor memory Disk Video Battery)/
cframe = vligb
cboxes = dagr
cboxfill = ywh
vaxis = axis1;
run;

I get error in LOG (just after the plot statement in the last code) that "expecting a variable name ; variable name not found ".

Any suggestions to correct the lof error.

Kindest Regards,
Mark
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
It would be useful to see your WHOLE log to see when/where things might start to go wrong.

One quick thing that might help would be for you to tell us what the PROC CONTENTS and PROC PRINT reveal about your SAS dataset DIS.MYSAS. Does the PROC CONTENTS show these variable names: Score GHz Price Processor memory Disk Video Battery as existing in the DIS.MYSAS dataset?? When you look at the PROC PRINT of DIS.MYSAS dataset, do you see the values that you expect to see?

If you don't see what you expect in the PROC PRINT and the PROC CONTENTS outputs, then that means the problem is farther up in the PROC IMPORT step. I'm not sure I understand the relationship of the first PROC IMPORT to the second PROC IMPORT step...as it looks like the data from the -second- PROC IMPORT is what you're plotting with PROC BOXPLOT.

However, if the PROC PRINT from the first PROC IMPORT shows the variables you expect to use and the second PROC IMPORT is being done on a copy of the first spreadsheet, that is one PROC IMPORT too many. You do not have to copy your Excel file into "C:\SAS" in order to import it into a SAS dataset. I do notice that the first PROC IMPORT uses more options than the second PROC IMPORT. If these are the same workbook/worksheet, then you really do need to use the same options every time you do the import. But, you know more about the data than I do -- so perhaps there's something different between the data in the first PROC IMPORT step and the second PROC IMPORT step that you didn't tell us about.

Alternately, you could try just using WORK.SAS1 in your PROC BOXPLOT and see whether that imported data has what you want to plot with PROC BOXPLOT.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 698 views
  • 0 likes
  • 2 in conversation