According to SAS not recognizing date format,
4 years and 6 months ago, MMYYSw. was unaccepted as SAS informat (but worked, and still works, as SAS format).
Nowadays, when I submit the following SAS piece of code:
DATA _NULL_;
INPUT x :MMYYS7.;
CARDS;
10/1946;
RUN;
I get "ERROR 48-59: The informat MMYYS was not found or could not be loaded".
My question is: do I get this error due to a coding error or because SAS still refuses MMYYS7. as an informat?
Thanks in advance for your help.
ANYDTDTE seems to work.
43 DATA _NULL_;
44 INPUT x :ANYDTDTE.;
45 format X mmyys.;
46 put x=date9. x=mmyys.;
47 CARDS;
x=01OCT1946 x=10/1946
Related
Being asked to read in and format dates in a premade sas file. Question is as follows:
Read in BIRTHDATE and DEATHDATE to recognize them as dates. (Create new variables called birthdate2 and deathdate2 respectively).
So, i've created a copy of the dataset:
data presidents_datefix;
set myfolder.presidents1;
run;
And am trying to use the input function to read the birth and deathdates in:
data presidents_datefix;
infile "presidents1"
input Presidents $ 1-38 #2 Birthdate date9. Deathdate date9.;
run;
Before running this datastep, the presidents1_datefix viewtable loads just fine. After the datastep, I get a warning message that reads:
"WARNING: The data set WORK.PRESIDENTS_DATEFIX may be incomplete. When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.PRESIDENTS_DATEFIX was not replaced because this step was stopped."
Then, when opening the viewtable, no observations exist anymore. I also get a series of error messages that say
ERROR 23-2: invalid option name
for every value of the input function.
Would really appreciate some help figuring out what I've done wrong and how I can fix it! Thank you!
I am working on SAS from the past 5 years and I am aware of only Base SAS ,SAS macro and Proc SQL and no other languages. Recently management has decided to migrate all the SAS code into python and they wanted us to learn PYTHON and convert all SAS codes into PYTHON(Thanks to Management). I am very much confused how to get started on this, I have read through some python online materials but I am wondering how to convert all the SAS code into python. To get started Can you please help me on the below sample SAS code how do we convert this in Python,
Please assume I have sample raw_data as following,
Name Age Val
Abc 23 100
Pqr 24 200
Xyz 26 400
I have below code which is the starting ,
%if %sysfunc(exist(raw_data)) eq 0 %then %do;
Data old_data;
set raw_data(where age>=24);
run;
%end;
proc sort data=olddata out=newdata;
by name descending val;
run;
Thanks in advance for your Help,
Regards,
Surya...
The following is the code:
data work.homework;
infile 'file-specification';
input name$ age height;
if age le 10;
run;
The raw data file is listed as the following:
A 35 71
B 10 43
C 9 12
I thought the correct answer should be 2. But it seems that it is 3 according to the answer sheet. Could anyone explain to me what is the reason? Many thanks for your time and attention.
data work.homework;
infile datalines;
input name$ age height;
if age le 10;
datalines;
A 35 71
B 10 43
C 9 12
;;;;
run;
NOTE: The data set WORK.HOMEWORK has 2 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
Now, as for how the answer might be three, I would look very carefully at the problem. There are two potential pitfalls.
One: is it possible a fourth record is read in? One that has blanks? If there is a blank line in the file, it's possible this would occur. Blank is indeed less than or equal to ten (check it!), so this line would qualify.
Two: if the line is
if age le 10 then ... ;
Then the automatic output is not affected.
As long as the code and data are exactly as above, though, two rows will be the correct answer to "How many observations will the dataset contain". (Not, how many observations will be processed in the data step loop, of course.)
I've created panel data by transposing columns, based on weeks, and some of the weeks never had observations, so those weeks never showed up as columns. Is there a reasonable way to insert the weeks that had no observations.
I need week0-week61, but currently I am missing week0, week4, week8... It seems silly to do this by hand in excel.
The simplest way is like this:
data ttt;
input id week0 week4;
datalines;
1 10 20
2 11 21
;
data ttt1;
set ttt;
array a{*} week0-week61;
run;
We read SAS xpt files to load data in .net. Everything works fine but recently we have encountered a problem where the customer has stored date as a numeric value in a column and provided a Format in the file header. The SAS viewer can display that data correctly using the given format but we have to load that data in .net in our program and we don't require SAS.
I recently found out that you can use the SaS LocalProvider with OLEDB but it turns out that it does not support Numeric formatting. So we are ending up with the wrong data in columns where data is stored as a numeric value with a format provided for it.
Can anyone please help me understand and resolve the issue with probably some code sample. I have looked around for code samples in .Net but with no luck so far for this issue.
Thanks in advance.
Regards,
Nasir
SAS Date values are stored as the number of days since Jan 1, 1960.
122
123 data _null_;
124 x=today();
125 put x=;
126 run;
x=19410
Today (2/21/2013) for example is 19410 days since 1/1/1960. Assuming you know your own software's date format (probably some number of days since some other date), you can perform the transformation on your own.
If it's relevant, SAS datetime values are # of seconds since 1/1/1960 00:00:00 .
128 data _null_;
129 x=datetime();
130 put x=;
131 run;
x=1677052885.5
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
Again, that's the time as of 08:00 2/21/2013.