- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Note: the data set WORK.LASVEGAS has 1 observation and 2 variables.
Thats what comes from that code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
NOte: the dataset work.lasvegas has 1 observation and 2 variables.
Thats the code from that code and doesn't give me the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content