My last one of these bad boys. Ok, so here goes...
Use the raw data file created previously. (ATTACHED)
Write a SAS® program that uses the PRINT procedure to produce a list that shows the contents of the raw data file. Illustrate that the gender categories of the original data were preserved. How about using the same proc print i used on the last question.
Proc print;
Title 'raw Data results';
*name of file;
Var Lowest_population Highest_population;
* would like those as headers, and list male, female on the left hand side;
*hrmm, will this work?;
run;
Write a second SAS® program to produce a report showing only the highest and lowest earning value or category for each gender. Ensure that labels are appropriate to convey the meaning of the data. Additionally, create a table that shows all of the earning variable contents for one gender category.
For the first part, highest and lowest, im taking that is the single lowest and highest for each gender, so the table will only have what 4 entries in it. The second part looks as if they want a list of each variable for all of one of the sexs. So, what about...this for the first part. I think this will do one of each entries, but not both, not sure on the proper method to single these out.
Proc print data=census;
Where sex='male';
Where Population>100000;
Run;
Proc print data=census;
Where sex='female';
Where population< 1;
Run;
For the second portion, would it be as simple as doing something like this? for all (variable) entries...
Data FullList;
infile '.csv' DSD Missover firstobs=2;
Input Gender $ Wages_Low Wages_High Estimated Max_Earnings;
Proc Print Data=FullList;
run;
Will this work? Am i on the right track?
Thanks!
Neither are correct.
Several points:
Proc print; ** No dataset specified - always specify the dataset
Title 'raw Data results'; ** Unless there is good reason keep titles outside procedures.
Var Lowest_population Highest_population;
run;
Proc print data=census; Where sex='male'; Where Population>100000; ** Where clauses do not work like this ** Look into the "and" operator Run; Proc print data=census; Where sex='female'; Where population< 1; Run;
Data FullList; infile '.csv' DSD Missover firstobs=2; ** No filename specified Input Gender $ Wages_Low Wages_High Estimated Max_Earnings; ** Don't use tab, this renders differently
** in different editors, use 2 spaces (can be configured in SAS options ** Missing run; Proc Print Data=FullList; run;
As an overview, nowadays it is far more important to make code as simple and readable as possible. Consitent casing, indentations, finishing blaocks etc all contribute to this, so let me take your code (and I don't guarentee this will run as I don't have the census or csv file so can't check):
/* Assumes there is a dataset called work.census */ title 'raw Data results'; proc print data=work.census; var lowest_population highest_population; run; proc print data=census; where sex='male' and population > 100000; run; proc print data=census; where sex='female' and population < 1; run; /* Assumes there is a file on C drive call mydatafile.csv, and it is in the format given by the input line */ data work.fullList; infile 'c:\mydatafile.csv' dsd missover firstobs=2; input gender $ wages_low wages_high estimated max_Earnings; run; proc print data=fulllist; run;
where does the pdf i already have come into play? I see the fullist report. I get that, and it will display from my existing .csv delimited file. However, i need to generate those 4 required variables from the exising report, unless i am reading it wrong. I suppose i am just clarifying that the original lines under the title will read code from the pdf file i had previously.
SAS can't read or combine PDFs, unless you're referring to text analytics and have SAS EM.
The PDF cannot be incorporated into your solution.
What PDF, I don't see a mention of it in your original post. Make sure you clearly provide all information - provide example test data (in the form of a datastep) and what you want out at the end. As for PDF, this is an "End Product" file format, and is of very little use trying to create anything from it. You need to store the data which created that report, and use that data in the next run.
PDF listed, and attached above.
SO your saying i need two .csv files to generate this from?
ods _all_ close;
ODS PDF FILE="/home//Program 1-results.pdf" startpage=NO;
TITLE COLOR=black 'Test';
title 'census';
proc print data=work.census;
var lowest_population highest_population;
run;
proc print data=census;
where sex='male' and population > 100000;
run;
proc print data=census;
where sex='female' and population > 100000;
run;
proc print data=census;
where sex='female' and population < 1;
run;
proc print data=census;
where sex='male' and population < 1;
run;
data work.fullList;
infile '/home/ Females Full Time Year Round.csv' dsd missover firstobs=2;
input gender $ wages_low wages_high estimated max_Earnings;
run;
proc print data=fulllist;
run;
quit;
Ok, i have this written out. However as you will see i still have 4 errors of which all are the same. Can anyone help me with this?
Error Work.file.census does not exist, actually its in here 5 times. I understand it is because the datset is not there. Do i simply just need to add
data=work.file.census;
Or can anyone offer me a suggestion? I have my pdf imported, and the second portion requires the csv and its in there, however i still get that one error 5 times. I have it entered incorrectly, i thought perhaps someone could shed some light on where i have errored in my ways.
PDF, and CSV attached.
thanks!
ERROR: File WORK.CENSUS.DATA does not exist.
Where's the code that creates the Census dataset?
No clue, thats the only error i have left. And no matter what i do its the same thing, im doing something wrong or leaving something out. I modified the code, and still have the same error 5x.
ods _all_ close;
ODS PDF FILE="//Program 1-results.pdf" startpage=NO;
TITLE COLOR=black 'Test';
title 'census';
data work.census;
infile '/home/.csv' dsd missover firstobs=2;
input gender $ wages_low wages_high estimated max_Earnings;
run;
proc print data=gender;
var lowest_population highest_population;
run;
proc print data=gender;
where sex='male' and population > 100000;
run;
proc print data=gender;
where sex='female' and population > 100000;
run;
proc print data=gender;
where sex='female' and population < 1;
run;
proc print data=gender;
where sex='male' and population < 1;
run;
data work.fullList;
infile '/home/ Females Full Time Year Round.csv' dsd missover firstobs=2;
input gender $ wages_low wages_high estimated max_Earnings;
run;
proc print data=fulllist;
run;
quit;
If you didn't import a datafile or save it from a previous session where are you expecting SAS to get the Census dataset from? You do have to provide the data....
The PDF and the CSV files both contain the data for each part of the program.
PDFs can't be used as a data source.
Your code in the last post changed. There's an import as the first step, fix that and The rest of the errors will disappear. I'm 99% sure you did this in your last question. Not sure it was ever correct there either, so I suggest reviewing how to import a CSV file.
http://stats.idre.ucla.edu/sas/faq/how-do-i-read-in-a-delimited-ascii-file-in-sas/
text file only?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.