Run Issues

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Run Issues

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;

Attachment

Accepted Solutions
Solution
‎04-25-2018 05:07 PM
Super User
Posts: 23,770

Re: Run Issues

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


All Replies
Super User
Posts: 23,770

Re: Run Issues

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;


 

Occasional Contributor
Posts: 11

Re: Run Issues

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.
Super User
Posts: 23,770

Re: Run Issues

[ Edited ]

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

Super User
Posts: 6,785

Re: Run Issues

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.

Super User
Posts: 23,770

Re: Run Issues

Posted in reply to Astounding
The data is actually column delimited, see the attached .sas file he included or the previous post.
Super User
Posts: 6,785

Re: Run Issues

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.

Super User
Posts: 23,770

Re: Run Issues

Posted in reply to Astounding

@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. 

 

Super User
Posts: 6,785

Re: Run Issues

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.

 

Super User
Posts: 23,770

Re: Run Issues

Posted in reply to Astounding

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.

Solution
‎04-25-2018 05:07 PM
Super User
Posts: 23,770

Re: Run Issues

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;
.....
Occasional Contributor
Posts: 11

Re: Run Issues

Thanks. Project due on Thursday. I'm last minute to say the least.
Super User
Posts: 23,770

Re: Run Issues

See my edits, once the file is correct everything runs as expected.
Occasional Contributor
Posts: 11

Re: Run Issues

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?

Occasional Contributor
Posts: 11

Re: Run Issues

I got it to run! nevermind! thanks!

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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