Please KurtBremer thank you very much. However, when i copy the macro and run after making the neccessary changes. Please this the error i keep getting. I have no clue how to fix this problem after several trials of fixing it. Thanks once again for the further direction 817 %macro data2datastep(edu,networks,,5); ERROR: Invalid macro parameter name ,. It should be a valid SAS identifier no longer than 32 characters. ERROR: A dummy macro will be compiled. 818 %local varlist msgtype; 819 820 %if %superq(obs)= %then %let obs=MAX; 821 822 %let msgtype=NOTE; 823 %if %superq(dsn)= %then %do; 824 %let msgtype=ERROR; 825 %put &msgtype: You must specify a data set name; 826 %put; 827 %goto syntax; 828 %end; 829 %let dsn=%qupcase(%superq(dsn)); 830 %if %superq(dsn)=!HELP %then %do; 831 %syntax: 832 %put &msgtype: &SYSMACRONAME macro help document:; 833 %put &msgtype- Purpose: Converts a data set to a SAS DATA step.; 834 %put &msgtype- Syntax: %nrstr(%%)&SYSMACRONAME(dsn<,lib,file,obs>); 835 %put &msgtype- dsn: Name of the dataset to be converted. Required.; 836 %put &msgtype- lib: LIBREF where the dataset resides. Optional.; 837 %put &msgtype- file: Fully qulaified filename for the DATA step produced. Optional.; 838 %put &msgtype- Default is %nrstr(create_&lib._&dsn._data.sas) in the SAS default 838! directory.; 839 %put &msgtype- obs: Max observations to include the created dataset. Optional.; 840 %put &msgtype- Default is MAX (all observations); 841 %put; 842 %put NOTE: &SYSMACRONAME cannot be used in-line - it generates code.; 843 %put NOTE- Use !HELP to print these notes.; 844 %return; 845 %end; 846 847 %if %superq(lib)= %then %do; 848 %let lib=%qscan(%superq(dsn),1,.); 849 %if %superq(lib) = %superq(dsn) %then %let lib=WORK; 850 %else %let dsn=%qscan(&dsn,2,.); 851 %end; 852 %let lib=%qupcase(%superq(lib)); 853 %let dsn=%qupcase(%superq(dsn)); 854 855 %if %sysfunc(exist(&lib..&dsn)) ne 1 %then %do; 856 %put ERROR: (&SYSMACRONAME) - Dataset &lib..&dsn does not exist.; 857 %let msgtype=NOTE; 858 %GoTo syntax; 859 %end; 860 861 %if %superq(file)= %then %do; 862 %let file=create_&lib._&dsn._data.sas; 863 %if %symexist(USERDIR) %then %let file=&userdir/&file; 864 %end; 865 866 %if %symexist(USERDIR) %then %do; 867 %if %qscan(%superq(file),-1,/\)=%superq(file) %then 868 %let file=&userdir/&file; 869 %end; 870 871 proc sql noprint; 872 select Name 873 into :varlist separated by ' ' 874 from dictionary.columns 875 where libname="&lib" 876 and memname="&dsn" 877 ; 878 select case type 879 when 'num' then 880 case 881 when missing(format) then cats(Name,':32.') 882 else cats(Name,':',format) 883 end 884 else cats(Name,':$',length,'.') 885 end 886 into :inputlist separated by ' ' 887 from dictionary.columns 888 where libname="&lib" 889 and memname="&dsn" 890 ; 891 quit; 892 893 data _null_; 894 file "&file" dsd; 895 if _n_ =1 then do; 896 put "data &lib..&dsn;"; 897 put @3 "infile datalines dsd truncover;"; 898 put @3 "input %superq(inputlist);"; 899 put "datalines4;"; 900 end; 901 set &lib..&dsn(obs=&obs) end=last; 902 put &varlist @; 903 if last then do; 904 put; 905 put ';;;;'; 906 end; 907 else put; 908 run; 909 %mend;
... View more