Please I need clarifcation on the code below. Thanks.
"data-type bis enclosed in parentheses and specifies one of the following: CHARACTER (or CHAR) | VARCHAR | INTEGER (or INT)."
proc sql; create table work.discount (Destination char(3), BeginDate num Format=date9., EndDate num format=date9., Discount num); quit;
I expect the data-type should be in parenthesis based on the syntax description above, e.g, Destination (char)(3). Please what am I missing?
... View more
Hello
Let's say that I want to create a data set based on sas_help.class data set.
The new data set will have only 2 columns: Var_name , Var_Value
What is the way to do it?
I expect that the new data set will have 95 rows (because in sas_help.class have 19 rows with 5 columns so 19*5=95)
thanks
... View more
Hello
With continue to previous post,
I want to create a new data set based on sashelp.class data set .
I want that in new data set will have 2 columns; Var_name ,Var_value.
I want it to be done only for numeric vars.
I want to identify the numeric vars automatically (Because I want to apply this code on different data sets)
proc sql;
create table numeric_Vars as
select libname, memname, name, type, length,
format, informat, label
from dictionary.columns
where libname = 'SASHELP' and memname = 'CLASS' and upcase(type) = 'NUM'
;
quit;
proc sql noprint;
select name into : Numeric_Vars_List SEPARATED by ' '
from numeric_Vars
;
quit;
%put &Numeric_Vars_List.; /**Age Height Weight**/
proc sql noprint;
select count(*) as nr_numeric_Vars into :nr_numeric_Vars
from numeric_Vars
;
quit;
%put &nr_numeric_Vars.;
data Long_Structure_Numeric_Vars_Data;
set sashelp.class;
array vv{&nr_numeric_Vars.} &Numeric_Vars_List.; /* _NUMERIC_ */
do j=1 to dim(vv);
Var_Name = vname(vv(i));
Var_Value = vv(i);
output;
end;
run;
The error in log is:
INFO: Character variables have defaulted to a length of 200 at the places given by: (Line):(Column). Truncation can result.
31:1 Var_Name
NOTE: Variable i is uninitialized.
ERROR: Array subscript out of range at line 31 column 19.
Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 j=1 Var_Name= i=. Var_Value= _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set SASHELP.CLASS.
WARNING: The data set WORK.LONG_STRUCTURE_NUMERIC_VARS_DATA may be incomplete. When this step was stopped there were 0
observations and 9 variables.
... View more
%macro sort (dname, new, svar) ;
proc sort data=&dname out=&new ;
by &svar;
run;
%Mend;
%sort(sashelp.class, demo1,sex);
data _null_;
if cexist("WORK.SORT") then
put "WORK.SORT exists";
else
put "WORK.SORT does not exist";
run;
Hi Experts,
here i am trying macro catolog exist or not but its giving wrong output please check where i did wrong
... View more