How do I import a csv file into the library or is it possible?
1) If the AGE is a group given as "18-50" then use
where age = "18-50";
If AGE is a number like 25 then you can use
where age between 18 and 50;
2) The title of your post is "How do I import a CSV file into the SAS library".
You got the solution to your question.
The new post dealing how to subset your date according to age group
should be posted as a new query.
My end goal is to create a frequency table..it lets me enter the source of the data but the data set is not showing up in the library
You can use either proc import:
proc import file="Path_and_FileName.csv"
out=test dbms=csv
replace;
getnames=yes; /* assume first line contains variable names */
run;
Try it and if any issue post the full log showing your code and messages.
Depending on data types you may have issues especially getting the wrong type.
If possible post also a sample lines from the csv file.
I have it now. I need a frequency table for an age group (18-50) along with gender
proc freq data=WORK.SYPHILIS; tables genderC genderB age / plots=(freqplot cumfreqplot); run; How do I write the code for an age group of 18-50
proc freq data=WORK.SYPHILIS; tables age sex_o genderC genderB / plots=(freqplot cumfreqplot); where age_group= '18 to 50'; run; Log: 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 /* 74 * 75 * Task code generated by SAS Studio 3.8 76 * 77 * Generated on '8/5/20, 12:06 PM' 78 * Generated by 'u49152646' 79 * Generated on server 'ODAWS02-USW2.ODA.SAS.COM' 80 * Generated on SAS platform 'Linux LIN X64 3.10.0-1062.9.1.el7.x86_64' 81 * Generated on SAS version '9.04.01M6P11072018' 82 * Generated on browser 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 82 ! Chrome/84.0.4147.105 Safari/537.36' 83 * Generated on web client 83 ! 'https://odamid-usw2.oda.sas.com/SASStudio/main?locale=en_US&zone=GMT-07%253A00&ticket=ST-58631-NKEgz3Gaqesii60Jleii-cas' 84 * 85 */ 86 87 proc freq data=WORK.SYPHILIS; 88 tables age sex_o genderC genderB / plots=(freqplot cumfreqplot); 89 where age_group= '18 to 50'; ERROR: Variable age_group is not on file WORK.SYPHILIS. 90 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE FREQ used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 1375.50k OS Memory 38572.00k Timestamp 08/05/2020 07:33:34 PM Step Count 265 Switch Count 0 Page Faults 0 Page Reclaims 242 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 91 92 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 104
It says that the age_group is not on the work.syphilis file. Where did I go wrong?
Your variable is named age. What kind of values does it contain?
The WHERE statement may be either
where age is between 18 and 50
or
where age is "18 to 50"
depending on age variable - is it an age of a person or
is it a group age/
It is a group age...(Age of people between the age of 18 and 50)
I got a frequency table from age 18-50....but I didn't use the word "is"..Does it matter
proc freq data=WORK.SYPHILIS; tables age sex_o genderC genderB RACE / plots=(freqplot cumfreqplot); where age between 18 and 50; run;
1) If the AGE is a group given as "18-50" then use
where age = "18-50";
If AGE is a number like 25 then you can use
where age between 18 and 50;
2) The title of your post is "How do I import a CSV file into the SAS library".
You got the solution to your question.
The new post dealing how to subset your date according to age group
should be posted as a new query.
Attached is my data. Again, my where statement was:
where age between 18 and 50
This is what it says:
proc freq data=WORK.SYPHILIS; tables age sex_o genderC genderB / plots=(freqplot cumfreqplot); where age_group= '18 to 50'; run; Log: 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 /* 74 * 75 * Task code generated by SAS Studio 3.8 76 * 77 * Generated on '8/5/20, 12:06 PM' 78 * Generated by 'u49152646' 79 * Generated on server 'ODAWS02-USW2.ODA.SAS.COM' 80 * Generated on SAS platform 'Linux LIN X64 3.10.0-1062.9.1.el7.x86_64' 81 * Generated on SAS version '9.04.01M6P11072018' 82 * Generated on browser 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 82 ! Chrome/84.0.4147.105 Safari/537.36' 83 * Generated on web client 83 ! 'https://odamid-usw2.oda.sas.com/SASStudio/main?locale=en_US&zone=GMT-07%253A00&ticket=ST-58631-NKEgz3Gaqesii60Jleii-cas' 84 * 85 */ 86 87 proc freq data=WORK.SYPHILIS; 88 tables age sex_o genderC genderB / plots=(freqplot cumfreqplot); 89 where age_group= '18 to 50'; ERROR: Variable age_group is not on file WORK.SYPHILIS. 90 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE FREQ used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 1375.50k OS Memory 38572.00k Timestamp 08/05/2020 07:33:34 PM Step Count 265 Switch Count 0 Page Faults 0 Page Reclaims 242 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 91 92 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 104
I figured it out..I did where age between 19 and 50;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.