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

I can't get this to run. There are 8 columns not including the _id_, _type_, _rhs_ columns (11 total)

I'm doing this for an Agribusiness project and need the program to tell me the most profitable enterprise(s) or crop(s) to produce

I'm not very familiar with this program

Here is the input.

 

data tobfarm;
infile datalines truncover;
input @1 _id_ Alfalfa Burley Sorg BHay WSDC CowCalf Corn Soybeans _type_ _rhs_;
datalines;

Profit 49 744 0 0 70 89.52 59.61 190 max
ContractedAcreage 0 1 0 0 0 0 0 0 le 10
Pasture 0 0 0 0 0 2.5 0 0 le 320
Land 1 0 1 1 1 0 1 1 le 275
January Labor 0 0 0 0 0 85 0 0 le 200
Febraury Labor 0 0 0 0 0 85 0 0 le 200
March Labor 0 0 0 0 0 85 0 0 le 200
April Labor .25 .5 .25 .25 1 85 .25 .25 le 200
May Labor 1 2.5 .25 1 1 85 .25 .25 le 200
June Labor 0 2 .25 .25 1 85 .25 .25 le 200
July Labor 0 .5 0 1 0 85 0 0 le 200
August Labor 1 2.5 0 0 0 85 0 0 le 200
September Labor .75 1.25 1.5 .75 .25 85 1.75 1.5 le 200
October Labor 0 1.25 1.5 .25 1.75 85 1.75 1.5 le 200
November Labor 0 1.25 .25 0 1.5 85 .75 .25 le 200
December Labor 0 .25 0 0 0 85 0 0 le 200
Capital 607 3306 400 436 630 1035 762 300 le 140000
;

proc lp;run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data tobfarm;
infile datalines truncover;
informat _ID_ $20.;
input @1 _ID_  $20. @21 Alfalfa     @33 Burley  @41 Sorg    @49 BHay
  @57 WSDC    @65 CowCalf @73 Corn    @81 Soybeans    @93 _type_ $
@105    _rhs_;
datalines;
.....

View solution in original post

16 REPLIES 16
Reeza
Super User

All this program does is read in a data set. It creates a SAS data set and does literally nothing else.

 


@jbbush42 wrote:

I can't get this to run. There are 8 columns not including the _id_, _type_, _rhs_ columns (11 total)

I'm doing this for an Agribusiness project and need the program to tell me the most profitable enterprise(s) or crop(s) to produce

I'm not very familiar with this program

Here is the input.

 

data tobfarm;
infile datalines truncover;
@input @1 _id_ Alfalfa Burley Sorg BHay WSDC CowCalf Corn Soybeans _type_ _rhs_;
datalines;

Profit 49 744 0 0 70 89.52 59.61 190 max
ContractedAcreage 0 1 0 0 0 0 0 0 le 10
Pasture 0 0 0 0 0 2.5 0 0 le 320
Land 1 0 1 1 1 0 1 1 le 275
January Labor 0 0 0 0 0 85 0 0 le 200
Febraury Labor 0 0 0 0 0 85 0 0 le 200
March Labor 0 0 0 0 0 85 0 0 le 200
April Labor .25 .5 .25 .25 1 85 .25 .25 le 200
May Labor 1 2.5 .25 1 1 85 .25 .25 le 200
June Labor 0 2 .25 .25 1 85 .25 .25 le 200
July Labor 0 .5 0 1 0 85 0 0 le 200
August Labor 1 2.5 0 0 0 85 0 0 le 200
September Labor .75 1.25 1.5 .75 .25 85 1.75 1.5 le 200
October Labor 0 1.25 1.5 .25 1.75 85 1.75 1.5 le 200
November Labor 0 1.25 .25 0 1.5 85 .75 .25 le 200
December Labor 0 .25 0 0 0 85 0 0 le 200
Capital 607 3306 400 436 630 1035 762 300 le 140000
;

proc lp;run;


 

jbbush42
Fluorite | Level 6
I know I haven't set this up properly. I was wanting to see what I left out/entered incorrectly to make it give me an analysis.
Reeza
Super User

You are neither reading in the data correctly or asking for any analysis correctly. First get your data read correctly, which I showed you how in your last post. That method worked with this file as well.

 

EDIT: the rest is fine, all you need to do is figure out the column delimiters similar to what I did for your last question and it runs fine:

 

NOTE: The data set WORK.TOBFARM has 17 observations and 11 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds


753 ;
754
755 proc lp;run;

NOTE: There were 17 observations read from the data set WORK.TOBFARM.
NOTE: PROCEDURE LP used (Total process time):
real time 0.09 seconds
cpu time 0.03 seconds

 

delete_proc_lp.PNG

Astounding
PROC Star

A couple of items to get started ...

 

First, use a LENGTH statement to define character fields.  This (or something like it) needs to go before the INPUT statement:

 

length _ID_ $ 17  _type_ $ 3;

 

Second, change the data to get rid of embedded blanks.  "OctoberLabor" not "October Labor".  If you would like, you can use other variations such as "October_Labor".  But no embedded blanks allowed.

 

There are other ways to handle the issues involved ... I'm trying to stick to an approach that involves the least amount of change.

 

Finally,  you may need to spell out more details than PROC LP.  I'm not sure about that and leave that part to you.  But if you continue to have problems, next time post the log rather than the program.  That's necessary for debugging in most cases.

Reeza
Super User
The data is actually column delimited, see the attached .sas file he included or the previous post.
Astounding
PROC Star

It's worse than that.  In the attached .sas file, there are tabs.

 

I try to answer what I can see, without looking at previous posts and usually without opening attachments.  Even without that information, the LENGTH statement would be a good idea.  I don't know if it's feasible to change the data and eliminate embedded blanks or not.

Reeza
Super User

@Astounding wrote:

It's worse than that.  In the attached .sas file, there are tabs.

 

 


Why would tabs be an issue?


@Astounding wrote:


I try to answer what I can see, without looking at previous posts and usually without opening attachments.  Even without that information, the LENGTH statement would be a good idea.  I don't know if it's feasible to change the data and eliminate embedded blanks or not.


That approach seems fair. 

 

Astounding
PROC Star

Tabs become an issue if they are not specified as legitimate delimiters:

 

If using column input, they throw off the column count.  Same when using formatted input.  If the column count is off, tabs can become part of the value of character variables.  And invalid data for numeric variables.  And if you're using list input it's a nightmare unless both tabs and blanks are legitimate delimiters.

 

Reeza
Super User

Interesting, no issues on my side with the tabs.

 


@Astounding wrote:

Tabs become an issue if they are not specified as legitimate delimiters:

 

If using column input, they throw off the column count.  Same when using formatted input.  If the column count is off, tabs can become part of the value of character variables.  And invalid data for numeric variables.  And if you're using list input it's a nightmare unless both tabs and blanks are legitimate delimiters.

 


 

You can also set the options to have tabs automatically converted to spaces but if they had tab set to 3 or 2 spaces that could be problematic.

Reeza
Super User
data tobfarm;
infile datalines truncover;
informat _ID_ $20.;
input @1 _ID_  $20. @21 Alfalfa     @33 Burley  @41 Sorg    @49 BHay
  @57 WSDC    @65 CowCalf @73 Corn    @81 Soybeans    @93 _type_ $
@105    _rhs_;
datalines;
.....
jbbush42
Fluorite | Level 6
Thanks. Project due on Thursday. I'm last minute to say the least.
Reeza
Super User
See my edits, once the file is correct everything runs as expected.
jbbush42
Fluorite | Level 6

I found your one post that was the edited top part and I copy pasted that into my inputs and it still won't run. Any chance you could attach the version you got to run so I could just download the input to run myself?

jbbush42
Fluorite | Level 6

I got it to run! nevermind! thanks!

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 1981 views
  • 6 likes
  • 4 in conversation