BookmarkSubscribeRSS Feed
SixUnder
Obsidian | Level 7

This is commented out in my code now, but is this what your referring to? I am getting pulled in so many directions, not by you. I thank you kindly for your responses. For the record i fixed my program last week, and it worked correctly. I had ot add a couple lines.

 

PROC EXPORT

DATA=DOLoop

DBMS=TAB

LABEL

OUTFILE='/home/.pdf'

Replace;

In addition, another part i have commented out is this, because as you said, I cant use a pdf file.

 

Data InputData;

infile '\home/.pdf'  dlm=' ' firstobs=2;

Input Gender $ Population Salary_Low Salary_High;

 

Proc Print Data=InputData;

Title 'pdf file from last week';

Var Gender Salary_Low Salary_High Population;

run; 

 

Reeza
Super User

This step needs to work, once this does the rest will be correct.

 

data work.census;
  infile '/home/.csv' dsd missover firstobs=2;
  input gender $ wages_low wages_high estimated max_Earnings;
run;
SixUnder
Obsidian | Level 7

Im missing something, that i get and I am racking my brain and making it worse. I keep commenting out code, and uncommenting it im almost down a rabbit hole... Its like my csv layout is wrong and im missing something important here...

Reeza
Super User

There's no filename in your CSV path, unless your file name is a period?

SixUnder
Obsidian | Level 7

Ok, i redid my previous work and changed it from a pdf to a text file. My table is displaying now, but none of the fields are populated. I am attaching my text file. and code. I am so tired of re-doing this bad boy... It should work, the fields just wont fill in now....

 

What needs modified?

 

/* Raw File*/

Data InputData;
infile '/home/ktylu10/Program 1-results.txt'  dlm=' ' firstobs=2;
Input Gender $ Earnings Population Low_wages3 High_Wages3;

Proc Print Data=InputData;
Title 'Raw File from Week 4';



*Lowest and Highest Value;
Proc Report Data=InputData nofs headline headskip
out=Reporting1;
Title 'Highest and Lowest Earning Value per Gender';
Columns Gender ('Earnings' Low_wages3 High_Wages3);
Define Gender / Group;
Define Low_wages3 / Analysis Min;
Define High_Wages3 / Analysis Max;
run;


* Lowest and Highest Earning per Gender;
Proc Report Data=InputData nofs headline headskip
out=Reporting2;
Title 'Highest and Lowest Earnings per Category and Gender';
Columns Gender ('Earnings' Low_wages3 High_Wages3);
Define Gender / Group;
Define Low_wages3 / Display;
Define High_Wages3 / Display;
run;


* Table;

Data Table;
set InputData;
Earnings = catx(' ', Low_wages3, 'to', High_Wages3);
Run;

proc tabulate data=Table order=formatted ;
class Gender Earnings;
Var Population;
table Earnings, Population*Gender; 
where Gender='Male';
run;

 

 

Reeza
Super User

@SixUnder wrote:

It should work, the fields just wont fill in now....

 

 

 

 



I don't know what that means. Are you receiving errors?

 

 

SixUnder
Obsidian | Level 7

No the headings of the columns list, and the gender type are there. However, none of the fields in the list, report, or table populate with any information.

 

No errors. image attached.

 

1 warning though, the feilds are there, just nothing from the text file trasferring into the tables.

 

NOTE: Invalid data for Low_wages3 in line 40 1-11.
NOTE: Invalid data for High_Wages3 in line 40 13-14.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
 
40 CHAR Male.$75000 to $99999.1168.75000.99999 38
ZONE 46660233333276223333303333033333033333
NUMR D1C5947500004F049999991168975000999999

results.jpg
Reeza
Super User

Because your data import isn't correct still. Garbage in, garbage out. 

 

Check the SAS dataset and see if it makes sense. Open the data set with the viewer. 

SixUnder
Obsidian | Level 7

I have changed the format of the input 7 times. Not once has it came out correctly in my display. No one will help me decipher what label is wrong or where, i have put a ton of effort into this. I am no master of SAS, I have been at this for 7 hours just today and I am still wrong, and not getting any output in those fields. Either the text files headers of the columns are wrong, or how i imported them for display in the new list, and tables is wrong. Unfortunately I have no more itme to work on this, i have to submit my work.

 

Input Gender $ Earnings Population Low_wages3 High_Wages3;

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The problem lies with one simple thing, communication.  What you are posting each time either doesn't match what is previous posted, or contradicts it.  There is no post here which clearly gives all the relevant data, or details all the issues.  Now, I have extracted what i can from the various posts, i.e. there is a PDF file, and a CSV file, and you want to print some things form it.  Then I have added code to read in this data (note that I copied the text from the PDF and put into datalines as PDF is not a datasource).  Then I took the code you had written and got it working.  Here is the result, note there is still a question on one of th eproc prints:

/* Read in your data */
/* The below I have copied the text from the PDF and put it into datalines */
data census;
  input obs Gender $ Low_wages3 High_Wages3 Population;
datalines;
1 Female 1 2499 7
2 Female 2500 4999 100001
3 Female 5000 7499 40
4 Male 5000 7499 100002
5 Male 34   34   0
;
run;

/* Read from CSV */
data fulllist;
  infile "s:\temp\rob\test1.csv" dlm="," firstobs=2;  /* Update to your path */
  input gender $ Wages_Low Wages_High Estimated Max_Earnings;
run;

/* Now we run the printing set */
ods _all_ close;
ods pdf file="s:\temp\rob\program 1-results.pdf" startpage=no;    /* Update to your path */
title color=black 'test';
title 'census';    /* <- this overwrites the previous title statement? */

/* This proc print will not work, there is no variable in the file you give called lowest_population and highest population 
proc print data=work.census;
  var lowest_population highest_population;
run;
*/
proc print data=census;
  where gender='Male' and population > 100000;  /* Note how the male matches exactly the data - in yours male != Male */
run;
proc print data=census;
  where gender='Female' and population > 100000;
run;
proc print data=census;
  where gender='Female' and population < 1;
run;
proc print data=census;
  where gender='Male' and population < 1;
run;

proc print data=fulllist;
run;

ods pdf close;

SixUnder
Obsidian | Level 7

I appreciate your assistance, but even after the fact. The code here, with updated file paths, i get no output data. Thanks for your help though.

Reeza
Super User

Then you're doing something wrong. I suspect you accidentally turned off your output with the ods _all_ close earlier.

 

Restart SAS UE and submit the code again. It should work perfectly.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 26 replies
  • 5134 views
  • 0 likes
  • 3 in conversation