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

Hi everyone

I have two questions for my code. The first code keeps showing "Variable RUN not found in data set WORK.SORT1" and the 2nd code keeps showing "file not exist". Please help me with these two codes. Thanks a lot! I attached two files below. REALLY hope someone help me! Thanks again!!!!

Code 1:

data exercise1;

input Patient 1-2 Weight 5-7 Height 9-10 Age 12-13 @15 BMI   Smoking $ 26-37  Asthma $;

cards;

14  167 70 65 23.9593878 never          no

9   .   74 64 .          never          yes

4   165 65 25 27.4544379 occasionally   no

2   152 67 60 23.8039652 heavy smoker   yes

13  161 70 77 23.0985714 occasionally   yes

1   143 64 55 24.5432129 occasionally   no

7   148 71 61 20.6395556 occasionally   yes

11  281 69 45 41.4919135 heavy smoker   yes

5   220 70 58 31.5632653 occasionally   no

6   182 64 26 31.2368164 never          no

8   190 66 74 30.6634527 occasionally   yes

12  . .  39 .          occasionally   yes

3   190 69 63 28.0550305 never          no

15  148 67 53 23.1775451 never          yes

10  152 65 61 25.2913609 never          yes

proc print data=exercise1;

run;

ods listing close;

     ods html body='C:\Users\joann\Desktop\ex1.html';

 

title1 'Asthma Patients';

title2 'Basic Data Set';

footnote 'Data from Medical Records';

options nonumber nodate;

proc sort data=exercise1 out=sort1;

by  Smoking Patient;

proc print data=sort1 noobs;

var Patient Asthma Age BMI;

by Smoking;

format BMI 5.2

run;

ods html close;

ods listing;

 

 

 

Code 2:

proc import out=Exercise2
datafile="C:\Users\joann\Desktop\Exam_Ex2.xls"
dbms=Excel replace;
run;
proc print; run;

title;
option nonumber nodate;
proc report data=Exercise2 nowd headline headskip;
column State_Name State_Abbrev_ Postal_Abbrev_ Area__Sq_Mi_ Population;
define State_Name/width=20 'State Name' left;
define State_Abbrev_/width=7 'State/Abbrev.' left spacing=7 ;
define Postal_Abbrev_/width=7 'Postal/Abbrev.' left spacing=10 ;
define Area__Sq_Mi_/format=comma7.0 width=8 'Area/(Sq Mi)' right spacing=8 ;
define Population/format=comma10. width=10 'Population' right spacing=10 ;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You're missing a semicolon on the format statement. So the RUN looks like part of the format statement and the variable isn't found. 

 

format BMI 5.2;

View solution in original post

6 REPLIES 6
wang_ziyi01
Calcite | Level 5

Here are 2 files needed. 

Thanks for helping out again.

Reeza
Super User

It's a bit hard to parse what you've posted. 

 

Can you explain the second error in more detail, or post the new code and log with the error?

 

In general, you should fix errors in the order they appear. 

wang_ziyi01
Calcite | Level 5

Here are some errors:

ERROR: Connect: Class not registered

ERROR: Error in the LIBNAME statement

And it also says the file cannot be found. I run this code before it worked, but I had no idead dit stopped running and gave me troubles. here is the code again:

 

proc import out=Exercise2
datafile="C:\Users\joann\Desktop\Exam_Ex2.xls"
dbms=Excel replace;
run;
proc print; run;

title;
option nonumber nodate;
proc report data=Exercise2 nowd headline headskip;
column State_Name State_Abbrev_ Postal_Abbrev_ Area__Sq_Mi_ Population;
define State_Name/width=20 'State Name' left;
define State_Abbrev_/width=7 'State/Abbrev.' left spacing=7 ;
define Postal_Abbrev_/width=7 'Postal/Abbrev.' left spacing=10 ;
define Area__Sq_Mi_/format=comma7.0 width=8 'Area/(Sq Mi)' right spacing=8 ;
define Population/format=comma10. width=10 'Population' right spacing=10 ;
run;

 

 

Reeza
Super User

@wang_ziyi01 wrote:

Here are some errors:

ERROR: Connect: Class not registered

ERROR: Error in the LIBNAME statement

And it also says the file cannot be found. I run this code before it worked, but I had no idead dit stopped running and gave me troubles. here is the code again:

 

 


You have an XLS file? If it worked and stopped, what changed in between?

 

I can't really help with path issues, though it doesn help if you post the full log. The log does include indications of what the solution might be if you're used to reading them.

Reeza
Super User

You're missing a semicolon on the format statement. So the RUN looks like part of the format statement and the variable isn't found. 

 

format BMI 5.2;

wang_ziyi01
Calcite | Level 5

OMG! Thanks! I am so stupid!!!! Thanks!!!!!! Do you know the second problem?

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 2121 views
  • 1 like
  • 2 in conversation