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

data Work.lasvegas;

if Score > 4.1230159 Then high_score = '1';

Else high_score = '0';

run; 

 

I put this code in and every Time the message is this: 

 

Variable Score is uninitialized. 

 

Any help into why my variable is like this? 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Goffy123 wrote:
Note: there were 1 observation read from dataset WORK.Lasvegas.
NOte: the dataset work.lasvegas has 1 observation and 2 variables.
Thats the code from that code and doesn't give me the results.

Did you pay any attention that you were told the first time you ran your example code that you destroyed the data set work.lasvegas and replaced with a single record data set with two variables that were missing?

Because you did not include the SET statement the first time.

 

Now you have to go back to where you got the original data to create work.lasvegas and start over.

Which is why I mentioned using that structure of code even with the SET statement can cause problems.

 

View solution in original post

11 REPLIES 11
novinosrin
Tourmaline | Level 20

are you missing the set statement that reads the input dataset records?

 

I am assuming your score variable is the input dataset

 

The code should likely be

 

data Work.lasvegas;

set your_inputdataset; /*this should have your variable score*/

if Score > 4.1230159 Then high_score = '1';

Else high_score = '0';

run; 

Goffy123
Calcite | Level 5
my data set is Work.lasvegas and SCORE is a variable within that. Using this SET step is not working. Any other help?
ballardw
Super User

Your code does not show anything where you are using existing data, such as a set statement.

So since you have not assigned any value to the variable SCORE it is "unitialized".

 

If you meant to refence and existing data set that has the variable score then you should have a set statement referencing that data set before attempting to use the variable.

Goffy123
Calcite | Level 5
My dataset is work.lasvegas and my score is a variable within that. This set step is not working any other help?
novinosrin
Tourmaline | Level 20

Did you try this?

 

data Work.lasvegas;

set  Work.lasvegas; /*this should have your variable score*/

if Score > 4.1230159 Then high_score = '1';

Else high_score = '0';

run; 

 

If yes, what's the log report plz

 

 

Goffy123
Calcite | Level 5
Note: There were 1 observation read from data set Work.LASVEGAS.
Note: the data set WORK.LASVEGAS has 1 observation and 2 variables.
Thats what comes from that code.
ballardw
Super User

@Goffy123 wrote:
My dataset is work.lasvegas and my score is a variable within that. This set step is not working any other help?

Try

 

data Work.lasvegas;
set Work.lasvegas;
if Score > 4.1230159 Then high_score = '1';

Else high_score = '0';

run; 

SET is an instruction that tells SAS to read data from a data set.

 

 

BTW habitual use of the

Data somesetname;

    set somesetname;

 

will cause you problems at some point when you make a minor coding issue as that coding structure completely replaces the data set and may make it extremely difficult to determine why something is not working.

Astounding
PROC Star

Because you have run this program, you have destroyed your data set work.lasvegas

 

You will need to re-create it first.  Then use it in a SET statement:

 

data new_dataset;

set Work.lasvegas;

if Score > 4.1230159 Then high_score = '1';

Else high_score = '0';

run; 

Goffy123
Calcite | Level 5
Note: there were 1 observation read from dataset WORK.Lasvegas.
NOte: the dataset work.lasvegas has 1 observation and 2 variables.
Thats the code from that code and doesn't give me the results.
ballardw
Super User

@Goffy123 wrote:
Note: there were 1 observation read from dataset WORK.Lasvegas.
NOte: the dataset work.lasvegas has 1 observation and 2 variables.
Thats the code from that code and doesn't give me the results.

Did you pay any attention that you were told the first time you ran your example code that you destroyed the data set work.lasvegas and replaced with a single record data set with two variables that were missing?

Because you did not include the SET statement the first time.

 

Now you have to go back to where you got the original data to create work.lasvegas and start over.

Which is why I mentioned using that structure of code even with the SET statement can cause problems.

 

Goffy123
Calcite | Level 5
Thank you so much you don't know how long I have been stuck on that aha

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 11 replies
  • 40999 views
  • 6 likes
  • 4 in conversation