03-02-2017
KDS_1113
Obsidian | Level 7
Member since
11-02-2016
- 13 Posts
- 7 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by KDS_1113
Subject Views Posted 2472 02-21-2017 09:05 AM 2490 02-20-2017 05:58 PM 2522 02-20-2017 08:36 AM 5218 02-19-2017 04:11 PM 5240 02-19-2017 02:22 PM 5243 02-19-2017 02:10 PM 5258 02-19-2017 01:27 PM 5279 02-19-2017 12:20 PM 3613 11-19-2016 10:42 PM 3622 11-19-2016 08:47 PM -
Activity Feed for KDS_1113
- Posted Re: Converting Character to Numeric and Removing Quotes on SAS Programming. 02-21-2017 09:05 AM
- Liked Re: Converting Character to Numeric and Removing Quotes for Shmuel. 02-21-2017 09:03 AM
- Liked Re: Converting Character to Numeric and Removing Quotes for Shmuel. 02-20-2017 05:59 PM
- Liked Re: Converting Character to Numeric and Removing Quotes for Kurt_Bremser. 02-20-2017 05:59 PM
- Posted Re: Converting Character to Numeric and Removing Quotes on SAS Programming. 02-20-2017 05:58 PM
- Posted Converting Character to Numeric and Removing Quotes on SAS Programming. 02-20-2017 08:36 AM
- Posted Re: Importing dataset with dates as column headers on SAS Programming. 02-19-2017 04:11 PM
- Liked Re: Importing dataset with dates as column headers for Shmuel. 02-19-2017 04:10 PM
- Liked Re: Importing dataset with dates as column headers for art297. 02-19-2017 02:58 PM
- Posted Re: Importing dataset with dates as column headers on SAS Programming. 02-19-2017 02:22 PM
- Liked Re: Importing dataset with dates as column headers for art297. 02-19-2017 02:15 PM
- Posted Re: Importing dataset with dates as column headers on SAS Programming. 02-19-2017 02:10 PM
- Posted Re: Importing dataset with dates as column headers on SAS Programming. 02-19-2017 01:27 PM
- Posted Importing dataset with dates as column headers on SAS Programming. 02-19-2017 12:20 PM
- Posted Re: Proc Transpose issue with Name on SAS Programming. 11-19-2016 10:42 PM
- Posted Re: Proc Transpose issue with Name on SAS Programming. 11-19-2016 08:47 PM
- Posted Proc Transpose issue with Name on SAS Programming. 11-19-2016 08:06 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 2 1 1
02-21-2017
09:05 AM
Shmuel, Thank you SO much! Your explanation was better than anything i've come across online (or in class!). I feel more comfortable trying your approach now.
... View more
02-20-2017
05:58 PM
Shmuel, thank you. I had not tried the code. I only started to learn about marcro's last week, so I'm not familiar with a_line, trucover, and other items in the code (i.e., vx). If you have the time, and don't mind, would you kindly explain what they accomplish?
... View more
02-20-2017
08:36 AM
This is a follow up to an problem I posted yesterday: https://communities.sas.com/t5/Base-SAS-Programming/Importing-dataset-with-dates-as-column-headers/m-p/334194#U334194 I have a .csv file with State, County, and population from 2000-2007. See attached sample. I was able to successfully load the file using proc import, however, I did not notice the population data loaded as character values. I started over and decided to import the file by copying and modifying code from the log; however, that's not working either. data WORK.POPULATION2001_2007 ; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ infile 'C:\population_by_county_2001_2007.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ; informat State $25. ; informat County $30. ; informat _1_1_2001 best12. ; informat _1_1_2002 best12. ; informat _1_1_2003 best12. ; informat _1_1_2004 best12. ; informat _1_1_2005 best12. ; informat _1_1_2006 best12. ; informat _1_1_2007 best12. ; format State $25. ; format County $30. ; format _1_1_2001 comma12. ; format _1_1_2002 comma12. ; format _1_1_2003 comma12. ; format _1_1_2004 comma12. ; format _1_1_2005 comma12. ; format _1_1_2006 comma12. ; format _1_1_2007 comma12. ; input State $ County $ _1_1_2001 /*NOTE: I'll change the column header's later using a macro that was suggested in yesterday's post*/ _1_1_2002 _1_1_2003 _1_1_2004 _1_1_2005 _1_1_2006 _1_1_2007 ; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ run; Here's a sample of the error message I'm getting: NOTE: Invalid data for _1_1_2007 in line 20 95-100. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--- 20 Alabama,Coosa County,"11,746","11,539","11,423","11,156","10,964","10,857","10,783" 102 State=Alabama County=Coosa County _7_1_2001=. _7_1_2002=. _7_1_2003=. _7_1_2004=. _7_1_2005=. _7_1_2006=. _7_1_2007=. _ERROR_=1 _N_=19 For one thing, it appears my data still has quotes around it. I thought having DSD in the infile statement was supposed to help with issues such as these. Any thoughts on what I'm doing wrong? Also, is there a better way to change data from character to numeric? I am a student who is new to SAS, so while there might be something that's glaring obvious to most, it may not be to me -- at least not yet 😉
... View more
02-19-2017
04:11 PM
Thank you for taking the time to answer my questions in detail.
... View more
02-19-2017
02:22 PM
Art297, thank you! I'm a student and just learning SAS, so can you help me understand the proc sql statement you provided? It appears you're creating a macro (I'm just learnning macros and find them somewhat confusing). Can you explain what the sections with arrows are doing? proc sql noprint; select catx('=y',name, <<<--------- year(input(translate(substr(name,2),'/','_'),anydtdte.))) into :vnames separated by ' ' from dictionary.columns <<<<-------- where libname='WORK' and memname='NEWFILE' and <<<<----- what is memname? first(name) eq '_' <<<---- is this calling on name created in line 2?
... View more
02-19-2017
02:10 PM
I saved the sample file as an excel file in error. The original IS a csv. Attached the first 3 lines of the original csv saved as text.
... View more
02-19-2017
01:27 PM
Thanks all - Attached is a sample of my data.
... View more
02-19-2017
12:20 PM
Morning - I have a .csv data set (not created by me) that contains city, state and then population by year (i.e., 1/1/2015, 1/1/2016, etc...). When I import the data into sas using the infile statement, it coverts the headers to _1_1_2015, _1_1_2016. I would prefer my column headers to be something like Y2015, Y2016, etc. As a way to get around this, I condsidered NOT importing the column headers and just later renaming them, but I'm wondering there's a better way to go about this. Here's an example of my code: proc import datafile="C:\example.csv" dbms=csv out=work.newfile replace; getnames=no; datarows=2; run; Next, I thought I could create a new table using a proc sql statement and renaming each of the date columns. I imagine there has to be a better way to go about this. Any advice?
... View more
11-19-2016
10:42 PM
Thanks, when i do a proc print it does show up correctly; however, when i try plotting I gett the same "Name of Former Variable"
... View more
11-19-2016
08:47 PM
Hi Jag - thanks for the suggestion; unfortunately, it didn't work. I keep seeing Name of Former Variable.
... View more
11-19-2016
08:06 PM
I have a dataset I'd like to transpose: I used the following code and get the table below: proc transpose data=gep2
out=gep3
NAME=Year;
id countrycode;
var _2001-_2018;
run; Isn't NAME=Year supposed to rename my first column? If not, what is the best way to rename this variable?
... View more